[HN Gopher] Create diagrams with code using Graphviz
       ___________________________________________________________________
        
       Create diagrams with code using Graphviz
        
       Author : adrianancona
       Score  : 502 points
       Date   : 2020-06-10 09:03 UTC (13 hours ago)
        
 (HTM) web link (ncona.com)
 (TXT) w3m dump (ncona.com)
        
       | magjac wrote:
       | Great article. You might also have use for
       | http://magjac.com/graphviz-visual-editor/ and the new
       | https://forum.graphviz.org
        
       | databasher wrote:
       | I use GraphViz to produce a visual, browsable version of the NIEM
       | data model. GraphViz can output images and HTML maps, which
       | allows easy building of clickable web pages with hover notes.
       | 
       | See the diagram at https://niem.github.io/model/4.2/nc/ItemType/
       | . Hover over a term to see its definition. Click on a term to
       | navigate to its diagram.
        
       | lalo2302 wrote:
       | What I've been craving for is a way to respect the order of the
       | nodes when being drawn. Since currently it re-orders them to
       | occupy less space.
       | 
       | With this I would be able to finish my data flow diagram out of a
       | functional programming project. To describe in a visual way how
       | the function calls are happening.
        
         | chrisseaton wrote:
         | Isn't the point of data flow that the order doesn't matter?
         | Otherwise it's control flow isn't it? I use GraphViz to render
         | both data flow and control flow without issue https://engineeri
         | ng.shopify.com/blogs/engineering/understand....
        
       | johnwalkr wrote:
       | Graphviz works great with LaTeX. It removes the pain point of
       | moving your workflow out of LaTeX.
        
       | ciceryadam wrote:
       | https://github.com/mingrammer/diagrams - uses graphviz under the
       | hood, and it's super easy to extend the list of available nodes.
       | Also you can tweak it with node/edge/graph attributes to fit in
       | your style/needs.
        
       | jimmySixDOF wrote:
       | RIP NetViz (90s - 2015) Back then it was one of the first to link
       | with a db of nodes to auto update diagrams the job I'm thinking
       | of had thousands of sites & it saved so much work once you had
       | templates set up.
        
       | FarhadG wrote:
       | Been super interested to write my own layout engine. Does anyone
       | have resources, tutorials, etc. that I should look into if
       | someone wants to write the layout engine that powers something
       | like GraphViz?
        
         | suyjuris wrote:
         | I was looking into that a while ago, but sadly I did not find
         | anything great. Back then I wanted to draw animated Binary
         | Decision Diagrams, so I had to come with an incremental (and
         | simple and fast) layout algorithm, which could determine
         | positions for new nodes without interfering with the original
         | graph. The result works fine, but it did require a fair amount
         | of tweaking. (The comments document these tweaks extensively
         | [1].)
         | 
         | If you want to write something more general, then that would
         | probably be much more complicated.
         | 
         | [1]
         | https://github.com/suyjuris/obst/blob/feb8e766ce226ca1afe862...
        
       | graphviz wrote:
       | We're reluctant to be exposed to too much anger about misfeatures
       | in 20 year old code that was basically a prototype that escaped
       | from the lab, but go ahead, ask us anything.
       | 
       | We've gotten a lot of help lately from Magnus Jacobssen, Matthew
       | Fernandez and Mark Hansen on cleaning up the website and the code
       | base, even some persistent bugs we could never find ourselves.
       | 
       | Improvements that would benefit the community the most?
       | 
       | - better default styles that don't look like troff from 1985
       | 
       | - better default layout parameters in neato than statistical
       | multidimensional scaling based on shortest path
       | 
       | - more expressive graph language with classes or templates
       | 
       | - more robust handling of error conditions like out of memory
       | 
       | - better documentation to help people find useful tools or just
       | know what they should be looking for
       | 
       | - find someone to donate a generic orthogonal routing algorithm
       | based on a modern algorithm since people want this
       | 
       | - it would be a big effort, but move the core algorithms to a
       | framework that supports interaction with layout generation
       | 
       | Hope this makes sense.
        
         | enriquto wrote:
         | Better integration with TeX, I want to put formulas inside the
         | graph using the exact same fonts as in the rest of my paper.
        
         | zackees wrote:
         | Hey there, I'm the owner of webgraphviz.com and I am totally
         | excited to see that it made it to the front page of
         | hackernews!!
         | 
         | THANK YOU for making this wonderful program.
         | 
         | Also special thanks to the emscripten team for their wonderful
         | transcompiler.
         | 
         | I am constantly amazed at all the WONDERFUL software that
         | exists on unix as single threaded applications (required for
         | emscriptem asm.js output). There could be a whole sub-culture
         | of webdev which uses these old unix programs. I feel like it's
         | an untapped resource, truly.
        
         | karatestomp wrote:
         | I'd rather have graphviz expose a kind of layout engine such
         | that it can take the size each node will occupy (determined by
         | whatever's going to draw them) and use that to create a layout,
         | feeding path info to something that can handle the actual
         | drawing, than have more drawing options in Graphviz itself. I
         | think that doing so is (so far as I could tell, last time I
         | tried) extremely awkward at best is why it's not embedded in
         | basically everything that has any need whatsoever to draw
         | graphs.
         | 
         | So, I guess:
         | 
         | > - it would be a big effort, but move the core algorithms to a
         | framework that supports interaction with layout generation
         | 
         | If that's what you mean by that.
         | 
         | It'd make it _way_ easier to pretty up Graphviz output. I 'd
         | rather have "renderer" applications that run on top of Graphviz
         | and have Graphviz itself lose all but its most basic build-in
         | drawing capabilities, than have more of that built into
         | Graphviz itself.
        
           | Karliss wrote:
           | I have used Graphviz that way. It wasn't too bad. The most
           | annoying part was inconsistency in input and output units.
           | Some properties expect values in pixels, some are in inches,
           | and dpi for input and output are different with only one of
           | them being configurable. Otherwise code was quite straight-
           | forward: create context, create nodes, create edges, set
           | attributes, run layout, read positions and edge path
           | coordinates, do the cleanup.
        
           | derefr wrote:
           | One problem with this is that--at least in some Graphviz
           | layout engines--"the size each node is going to occupy" is
           | chosen to minimize the energy/stress of the graph, sort of
           | like how line breaks on TeX pages are chosen to optimize for
           | whole-page metrics.
           | 
           | For example, in a graph with only two nodes, where each node
           | contains a long text string, there is no "pressure" on the
           | nodes, so the default result might be to not break the text,
           | creating two wide, short node-boxes, and then to arrange them
           | with one above the other. Whereas if you have many such nodes
           | in a densely-connected web, the text in them will likely be
           | wrapped in order to make the nodes more box-shaped, so that
           | nodes can fit between the cuts of the pairwise-acute
           | spirograph-like edge lines.
           | 
           | In order to resolve this sort of layout, Graphviz has to
           | understand a lot of things about fonts, padding, and borders
           | (just like TeX does.) It's already doing "rendering" at that
           | point, even if the result gets thrown away.
        
         | pspeter3 wrote:
         | I'm excited for better default styles and colors. I love the
         | text editing experience of Graphviz but spend a lot of time
         | trying to style it unfortunately.
        
         | dreamcompiler wrote:
         | I love graphviz and have used it as part of my job for over 15
         | years.
         | 
         | That said, I have spent entirely too much time manually
         | searching through the 100-odd dimensional Graphviz parameter
         | space trying to get aesthetic results. So much time in fact
         | that occasionally it's easier to fire up Omnigraph and draw the
         | thing manually.
         | 
         | Graphviz would be ideal if it had some kind of meta-parameter
         | settings that could reduce the tendency of its output to
         | resemble an unreadable rats nest when the number of nodes
         | exceeds about 20. I know that's part of the point of neato vs.
         | dot, and that some parameters _are_ effectively meta-
         | parameters, but Graphviz still needs a better  "porcelain" (in
         | git-speak) with fewer dimensions.
        
         | haolez wrote:
         | Sincerely, I think graphviz is great the way it is. I wouldn't
         | change the graph language and most of the suggested changes
         | would be "nice to have".
         | 
         | Thanks for your hard work on it!
        
           | gmfawcett wrote:
           | Agreed 100%. I don't care if graphviz looks a bit dated --
           | it's straightforward and easy to generate. (I wouldn't say
           | "no" to having more layout algorithms, though!)
           | 
           | My favourite personal use of Graphviz: A few years ago I
           | inherited a large, legacy codebase that was very hard to
           | understand -- full of global state modified from dozens of
           | functions, obscure function names, etc. I used a C parser
           | (forget which one) to convert the code to a set of ASTs, and
           | then hacked up a Web-based, interactive graph generator,
           | using Graphviz to create the interactive SVGs. The "app" let
           | you click on a function (node) and zoom in to examine its
           | callers, callees, global accesses, global mutations, etc.,
           | with a "radius" parameter to decide how much of the large
           | graph you wanted to see. Every node was clickable, and would
           | ask the Web app to generate a new graph centered on that
           | node.
           | 
           | It was an awful, throwaway hack, and was only about 90%
           | accurate due to parsing/preprocessor challenges. (At times I
           | resorted to annotating the code with magic comments to
           | facilitate graph generation -- not a sustainable approach.)
           | But a day spent hacking with Graphviz dramatically improved
           | my learning rate, and it was also useful in helping describe
           | the code to others.
        
         | Dayshine wrote:
         | > - find someone to donate a generic orthogonal routing
         | algorithm based on a modern algorithm since people want this
         | 
         | > - it would be a big effort, but move the core algorithms to a
         | framework that supports interaction with layout generation
         | 
         | Yup, I think these are the ones that mean I never actually end
         | up using Graphviz for anything :)
         | 
         | If I'm generating graphs, I want them laid out in a
         | hierarchical style.
         | 
         | To do that, I need a library which can do that layout.
         | 
         | Those libraries are often written in a higher level language
         | like C#, Java, etc, which come with their own simple drawing
         | layer.
         | 
         | And then I don't need Graphviz anymore! (not that I'm
         | suggesting graphviz should change)
        
           | bmh100 wrote:
           | I'm curious to know which libraries you use.
           | 
           | Also, in my own experience, I was able to get hierarchical
           | layouts Graphviz by using directional graphs with subgraphs.
        
           | criddell wrote:
           | So what library do you use for hierarchical layouts?
        
         | fermienrico wrote:
         | > - better default styles that don't look like troff from 1985
         | 
         | Design is not something that should be tied to a particular
         | decade. It's not fashion. Good design is timeless and only
         | adopts to new technologies/media. Design is how well a
         | particular solution works for the purpose of it. If it looks
         | like 1985 and works well, there is absolutely no reason to
         | change it. If it doesn't, then there is no need to look at
         | "modern trends", instead we need to go back to the drawing
         | board and find out what the _problem_ is first.
         | 
         | Can you identify the problem with the design besides the
         | superficial aesthetic (which can be easily themed)?
        
           | thecupisblue wrote:
           | > Design is how well a particular solution works for the
           | purpose of it
           | 
           | That's one half. The other one is how people feel while using
           | it. 1985 aesthetic makes people feel bad. Thus design is half
           | bad. Or, for you maybe, half good.
        
             | yjftsjthsd-h wrote:
             | Speak for yourself; some of us think computer aesthetics
             | peaked by the 90s ;)
        
               | optimuspaul wrote:
               | and some of us are still waiting for aesthetics to reach
               | computers ;)
        
           | jakear wrote:
           | > it's not fashion
           | 
           | Many would argue good fashion is timeless as well. A good
           | chunk of haute couture from decades past would be seen as
           | modern and appealing today. (Which is why the houses like to
           | repackage and ship them as such...)
        
             | fermienrico wrote:
             | I disagree, accordingly Wikipedia:
             | 
             | > Fashion is a popular aesthetic expression at a particular
             | time, place and in a specific context, especially in
             | clothing, footwear, lifestyle, accessories, makeup,
             | hairstyle, and body proportions.
             | 
             | Fashion is inexplicably linked to a particular time. Just
             | like Art - Art evolves with time and it is part of the
             | culture, current events, etc.
             | 
             | Design is not (unless you want to include say media as it
             | changes through time. For e.g. print -> digital media).
        
           | smnrchrds wrote:
           | > Design is not something that should be tied to a particular
           | decade.
           | 
           | Design does not exist in a vacuum. Technological progress,
           | for example, creates the need for design change. Microsoft's
           | switch from a serif to a sans serif font as the default
           | typeface for Word was a good move, because we rarely print
           | documents anymore and a the best design for print is not the
           | same as the best design for screens.
           | 
           | 20th century physics books had a distinct design for
           | illustrations. It was beautiful and functional. But it was
           | also designed around the limitations of their eventual
           | monochrome (not even greyscale) print. A 2020 textbook does
           | not have the same limitations and should not be designed with
           | the same set of constraints.
        
         | 13415 wrote:
         | No critique from me, instead a big thanks from me to you and
         | anyone else who worked on graphviz!
         | 
         | I've used it a few times for visualizing aspects of my
         | research, usually by writing .dot files directly from Racket.
         | It turned out to be quite useful.
        
         | nxpnsv wrote:
         | Anger, what's wrong with people? For the record, I love
         | graphviz. Thanks!
        
         | t-writescode wrote:
         | I have been nothing but happy to use graphviz and recommend it
         | regularly. Thank you for all of your work, truly.
        
         | jcims wrote:
         | Been using graphviz on and off for ~20^H^H15 years (seems like
         | 20) and it was my introduction to graph theory and concepts.
         | Just wanted to thank the team for maintaining an incredibly
         | useful and versatile tool.
        
         | wnoise wrote:
         | > look like troff from 1985
         | 
         | This is a feature, not a bug.
         | 
         | The rest would be nice to have, though.
        
           | mumblemumble wrote:
           | I was thinking something similar. The default styles don't
           | look super shiny, I suppose, but they are clean, which I
           | appreciate. All in all, I think it does a good job of
           | supporting my main reason for choosing graphviz over
           | something like Visio: It encourages me to get the
           | illustration done and then get on with my day without getting
           | caught up with trying to make everything perfect.
           | 
           | I will turn to Visio if I need to make something
           | presentation-quality, so there's that.
           | 
           | I have similar feelings about the lack of ability to fine-
           | tune the layout: I've started seeing it as a feature, because
           | it gives me a great feedback mechanism: If the graph is too
           | complicated for Graphviz to lay out nicely, I take that as a
           | sign that the thing the graph represents needs to be
           | simplified. I've even gone so far as to incorporate Graphviz
           | into my definition of done for a refactoring project: I kept
           | a dotfile representing the current state of the dependency
           | graph, and stopped refactoring when the rendered graph
           | stopped making my eyes water.
        
         | tmaly wrote:
         | I just want to say thank you for releasing this. I have been
         | using graphviz since 2008. It is part of an internal tool to
         | visualize information in the financial industry. It has been a
         | life saver.
        
       | davidgerard wrote:
       | I heartily recommend the Graphviz plugin for MediaWiki.
       | 
       | Also, http://www.webgraphviz.com/
        
       | kmstout wrote:
       | I've gotten a lot of mileage from Graphviz over the years. As an
       | example outside of work, I wanted a way to depict parse trees for
       | an article I was writing. So, after I wrote an EBNF parser
       | generator (great fun!), I wrote a little utility to apply a
       | grammar to stdin and emit to stdout a JSON representation of the
       | resulting parse tree; another utility handles converting the JSON
       | to dot, which I can plot at my leisure.
       | 
       | https://github.com/reindeereffect/tools-from-blog/tree/maste...
        
         | jjice wrote:
         | I was writing a parser recently, and I was fed up with having
         | to look at a textual tree output. I did a bit of Googling,
         | found Graphviz, and I had the whole thing working in like 15
         | minutes. I think it's absolutely essential to me now anytime I
         | work with trees/graphs that I need to visualize.
        
       | mendeza wrote:
       | Great tutorial! Is there a way to extract the bounding box of
       | nodes, and the endpoints of lines? This would be useful to
       | generate ML models to automatically parse graphs!
        
       | npiit wrote:
       | Graphviz is for noobs. Try TikZ, aka the Gigachad of vector
       | graphics. I spent more time creating TikZ diagrams than actually
       | writing my whole MSc. thesis.
        
         | enriquto wrote:
         | > Graphviz is for noobs. Try TikZ, aka the Gigachad of vector
         | graphics.
         | 
         | Maybe you are right, in today's decaying world. But any
         | civilized person can see that tikz, latex and even graphviz are
         | all ultimately hipster tools. Real men of course use pic and
         | troff.
        
           | npiit wrote:
           | Now, 28 year old me after leaving academia and learning the
           | superpower of TikZ, LaTeX and Beamer, I just use draw.io and
           | google docs/slides.
        
             | enriquto wrote:
             | the horror, the horror
        
         | chrisseaton wrote:
         | I don't believe TikZ does any kind of automatic layout - that's
         | what most people use Graphviz for I believe.
        
         | jandrese wrote:
         | > I spent more time creating TikZ diagrams than actually
         | writing my whole MSc. thesis.
         | 
         | Isn't this the primary problem with TikZ? It makes you do all
         | the time consuming layout stuff by hand. With Graphviz you just
         | chuck your data at it and get results instantly. Sure it won't
         | be eye-optimized, but it also didn't require work on your part,
         | nor will it require more work on your part when your data
         | changes.
        
       | tejtm wrote:
       | DOT all the things!
       | 
       | (simple) Makefiles [0] XML [1] Json [2]
       | 
       | [0] https://github.com/TomConlin/MakefileViz [1]
       | https://github.com/TomConlin/xpath2dot [2]
       | https://github.com/TomConlin/json_to_paths
        
       | simonsarris wrote:
       | If you need a library with a _lot_ more power out of the box
       | (interaction tools, undo manager, data binding, lots of layouts,
       | and many more visualization options), I make GoJS:
       | https://gojs.net/latest/index.html
       | 
       | It's not free, however, though you can use the evaluation version
       | indefinitely if you wanted to make your own graphs for personal
       | use.
        
       | kristiandupont wrote:
       | I'm going to hijack this thread to ask if anyone knows of a
       | library that creates "hand drawn"-style sequence diagrams from
       | code? I basically want this: https://bramp.github.io/js-sequence-
       | diagrams/ -- but sadly, this one only seems to run inside a
       | browser.
        
         | fsiefken wrote:
         | there must be away to run it in a headless browser en
         | screencapture and parse the output as png
        
           | AlexITC wrote:
           | Actually, it's pretty simple, just include
           | https://github.com/markushedvall/plantuml-encoder and call
           | "https://www.plantuml.com/plantuml/img/" + encode(text);
           | 
           | That's what I did on collabuml.
        
           | kristiandupont wrote:
           | Surely there is. It just seems overly complicated to me.
        
         | pbsds wrote:
         | This one is also web-based, but it takes graphviz source:
         | https://sketchviz.com/new
        
         | mpk wrote:
         | PlantUML supports this https://plantuml.com/handwritten
         | 
         | Add this to any diagram to get the effect you want,
         | skinparam handwritten true       skinparam monochrome true
         | 
         | Demo: https://tinyurl.com/ycdu7owa
        
           | kristiandupont wrote:
           | Thank you
        
           | AlexITC wrote:
           | Also, you can use https://collabuml.com to collaboratively
           | build diagrams.
        
       | hnarayanan wrote:
       | One interesting thing is that graphviz can output to many
       | formats, including SVG. This makes it great for websites, where
       | one can later do things like later tweak the colours on the fly.
       | 
       | e.g. https://harishnarayanan.org/writing/kubernetes-django/
        
         | vidarh wrote:
         | Many years ago I wrote an XSL file that uses the Graphviz SVG
         | output and applies gradients and shadows (the repo also has a
         | couple of tiny tools that output graphviz graphs):
         | 
         | https://github.com/vidarh/diagram-tools/tree/master
        
         | lihaoyi wrote:
         | Being SVG also means you can style them via CSS, allowing
         | simple interactivity. For example, you can make graph edges
         | change color or become thicker when you mouse over them, making
         | it easier to follow edges in a large messy graph
        
         | josteink wrote:
         | SVGs created by GraphViz (and possibly in general?) also has
         | the benefit of being searchable within a browser, etc.
         | 
         | So if you have a huge diagram and want to find a node of
         | interest, with a SVG, it's only a quick CTRL-F away.
        
       | dan199 wrote:
       | I find plantuml a more useful abstraction for software stuff
       | (uses graphviz under the covers)
       | 
       | https://plantuml.com/
        
       | RobinL wrote:
       | At ObservbleHQ they use this to automatically visualise
       | dependencies: https://observablehq.com/@observablehq/notebook-
       | visualizer
       | 
       | More generally, Observable gives you a 'playground' where you can
       | interactively see graphviz results:
       | https://observablehq.com/@observablehq/graphviz
       | 
       | Another option - which for some applications is visually more
       | appealing - is Elk:
       | https://observablehq.com/@observablehq/notebook-visualizer-e...
       | 
       | There's a simple start notebook here:
       | https://observablehq.com/@tmcw/elk
        
       | jetrink wrote:
       | I found a great use for Graphviz recently. I needed to implement
       | a model that was created by a scientist with no programming
       | experience outside of a Fortran class in the early 1980s.
       | Meanwhile, I didn't have much knowledge of the subject matter or
       | terminology. The model was described in a multipage Excel file
       | and an accompanying PDF and I implemented it in Clojure.
       | 
       | In order to help us communicate, I wrote a script that built a
       | data-dependency graph directly from the code and produced a
       | diagram with Graphviz for the scientist to review. It helped us
       | to catch a couple errors resulting from my misinterpretations and
       | it gave the scientist confidence that the code accurately
       | reflected his design.
        
         | Heliosmaster wrote:
         | Also i think it's a great use case for the data-drivenness of
         | clojure :)
        
         | truculent wrote:
         | I have used rather nice clojure library that also uses graphviz
         | under the bonnet, with great success:
         | 
         | https://github.com/Engelberg/ubergraph
         | 
         | Did you use something similar or roll your own?
         | 
         | In any case, your project sounds great and I am glad it was a
         | success.
        
           | jetrink wrote:
           | I used Rhizome[1]. (It looks like it is no longer being
           | maintained, but I didn't run into any issues.)
           | 
           | 1. https://github.com/ztellman/rhizome
        
         | macintux wrote:
         | That's fantastic. You should write a blog post on that.
        
         | tetris11 wrote:
         | There's an Emacs package which also uses Graphviz in the same
         | way to show function dependencies during development:
         | 
         | https://github.com/mtekman/elisp-depmap.el
        
       | jxramos wrote:
       | Navigation is very important too for large graphs. Go with yEd
       | instead and graphml, networkx is great too
       | https://networkx.github.io/documentation/stable/reference/re...
        
       | sevensor wrote:
       | I really like graphviz for visualizing the call graphs generated
       | by the Python profiler.
        
       | machawinka wrote:
       | I have used it to visualize dependency trees for several thousand
       | nodes and show my team loops and broken deps. For this kind of
       | situations, a picture is better than a thousand lines of code.
        
       | ppsreejith wrote:
       | One of my favourite online graphviz editors for quickly creating
       | something is: https://dreampuf.github.io/GraphvizOnline/
        
       | kinow wrote:
       | Great post. I've used it to generate UML diagrams from databases
       | with sqlalchemy, and more recently to generate protobuf diagrams
       | in Python (needed it quickly to update some documentation):
       | https://github.com/kinow/protobuf-uml-diagram
       | 
       | One thing that I think was not mentioned in the article, are
       | invisible nodes, which are really handy:
       | https://stackoverflow.com/search?q=invisible+node+%5Bgraphvi...
       | 
       | Some times the existing layouts, ranks, clusters, etc, won't help
       | you to produce the diagram you have in your mind. So instead of
       | giving up and drawing it in draw.io or Inkspace (which I used to
       | do), a co-worker showed me how he was using this technique in
       | several of his diagrams.
        
       | bollu wrote:
       | There seems to be somewhat of a myth that it's hard to get
       | GraphViz diagrams to "look nice". I (obviously biased) feel that
       | the diagrams I generated for my reference implementation of RETE
       | look quite clean: https://github.com/bollu/rete#example-rete-
       | diagrams-to-learn...
        
         | bvrmn wrote:
         | The instant place to look for graphviz issues is a distance
         | between arrow head/tail to node. But yes your diagrams are very
         | clean indeed!
        
       | typpo wrote:
       | I run a web service "QuickChart" that renders Graphviz charts to
       | PNG/SVG so you can easily bring graphviz diagrams into a web app
       | or spreadsheet. Some Graphviz fans may find it useful (it's
       | intended as a replacement for the old Google Image Charts
       | graphviz renderer).
       | https://quickchart.io/chart?cht=gv&chl=<DOT here>
       | 
       | e.g.                  https://quickchart.io/chart?cht=gv&chl=digr
       | aph%20MyGraph%20%7Bbegin%20-%3E%20end%7D
       | 
       | The service is open source: https://github.com/typpo/quickchart
        
       | alexchantavy wrote:
       | For Python I love using Pyan
       | (https://github.com/davidfraser/pyan, though I'm not sure this is
       | the main repo but it's the first result on Google and it seems to
       | work fine). My workflow is
       | 
       | cd ~/projectdir pyan3 path/to/file/i/want.py --uses --no-defines
       | --colored --grouped --annotated --dot > dotfile.dot dot -Tsvg
       | dotfile.dot > diagram.svg
        
       | cosmic_quanta wrote:
       | How convenient, I just added graphviz support to my Pandoc
       | filter, pandoc-plot. It renders graphviz code blocks into graphs
       | (also works with other plotting toolkits).
       | 
       | https://github.com/LaurentRDC/pandoc-plot
        
       | leephillips wrote:
       | I use this quite often. Graphviz and the dot language are really
       | useful tools. Here is my roundup of a collection of free-software
       | network graphing tools:
       | 
       | https://lwn.net/Articles/639998/
        
       | buserror wrote:
       | I use graphviz a lot; here I generate a 'call graph' of the
       | codebase of simavr[0] as a pdf for example [1]. But I also use it
       | for introspection for complex data structure.
       | 
       | [0]: http://github.com/buserror/simavr [1]:
       | https://github.com/buserror/simavr/blob/master/doc/simavr_ca...
        
         | yboris wrote:
         | This is excellent! Thank you for the share!
         | 
         | I'm working on a Typescript Call Graph [0] and am leaning
         | towards D3 for my visualization. But I hope I can generate
         | something as pretty and useful as your link [1]
         | 
         | [0]: https://github.com/whyboris/TypeScript-Call-Graph
        
           | mthoms wrote:
           | Nice. This will be useful, I'm looking forward to it.
           | 
           | Are you aware of any similar tools for creating class
           | diagrams from TS code?
        
             | yboris wrote:
             | The closest I found was TS-Call-Graph [0] which works well
             | but only on _classes_ while mine is aimed at _functions_
             | 
             | I have a very rough draft of a graph working [1] (currently
             | hardcoded with a specific function name) but I intend to
             | make it interactive and to have more than one visualization
             | of the files.
             | 
             | [0] https://github.com/Deskbot/TS-Call-Graph
             | 
             | [1] https://github.com/whyboris/TypeScript-Call-
             | Graph/pull/1
        
       | ngcc_hk wrote:
       | Still remember learning to generate dot by lisp in the book
       | learning lisp one game at a time.
        
       | zozbot234 wrote:
       | I like Graphviz, but it's sad that we get such a tiny selection
       | of graph-drawing algorithms to go with it. For instance, I don't
       | see a way to draw a force-directed layout that also tries to
       | account for edge direction, like a more flexible version of
       | _dot_.
        
       | [deleted]
        
         | [deleted]
        
       | mv4 wrote:
       | Used Graphviz to visualize gstreamer pipelines, and it was
       | awesome for the task.
        
       | Der_Einzige wrote:
       | You might as well just use something like plantUML instead of
       | this from a productivity standpoint.
       | 
       | However, I don't want to discount the value of Graphviz. Python
       | has a little known class diagram generator built into pylint
       | which uses Graphviz for its rendering and its pretty cool. You
       | can find out just how bad your #BIGCORPS code architecture is
       | just by checking a reasonably large project with Pylints class
       | diagraming tool...
        
       | Schiphol wrote:
       | I like graphviz a lot, but I almost always end up using
       | [Tikz](http://www.ctan.org/tex-archive/graphics/pgf/), which is
       | quite a bit more flexible.
       | 
       | One huge advantage of Tikz is that you can use LaTeX equations
       | natively. E.g. subscripts and superscripts in graphviz involve
       | jumping through a few hoops, iirc.
        
         | pletnes wrote:
         | Does it have graph-drawing included?
        
           | kragen wrote:
           | Yes, part of TikZ is a clone of Graphviz, but implemented in
           | LaTeX.
        
             | mkl wrote:
             | And Lua for the more advanced layout calculations, which
             | need LuaLaTeX.
        
           | Schiphol wrote:
           | That's one of its main uses. One thing it does not do (or I
           | don't know how) and graphviz does, though, is arranging nodes
           | intelligently so as to minimize clutter and edge distances.
           | That's one of the nice things in graphviz.
        
             | enriquto wrote:
             | > One thing it does not do (or I don't know how) and
             | graphviz does, though, is arranging nodes intelligently
             | 
             | That's exactly what "graph drawing" means [0]. Can tikz
             | choose the position of the vertices itself or you have to
             | specify the positions yourself? If it is you who chooses
             | the positions, then tikz does not do "graph drawing".
             | 
             | [0] https://en.wikipedia.org/wiki/Graph_drawing
        
               | mkl wrote:
               | Yes, TikZ can position the vertices itself. E.g.
               | http://www.tcs.uni-
               | luebeck.de/downloads/papers/2011/2011-con...
               | http://www.tcs.uni-
               | luebeck.de/downloads/mitarbeiter/tantau/2...
               | https://tex.stackexchange.com/questions/203692/how-to-
               | automa...
        
               | enriquto wrote:
               | That's great! Did these people really implement graph
               | drawing algorithms as latex macros, or does it call an
               | external program? I'm afraid to look it myself, lest I
               | discover the truth.
        
               | mkl wrote:
               | Some of it is LaTeX, but the more intensive algorithms
               | are done with embedded Lua, using LuaLaTeX. There is no
               | external program.
        
               | nyir wrote:
               | Wow, that was a long time ago, very fun project to work
               | on. But yeah, without deep knowledge of the TeX side
               | you'd likely still struggle a bit to understand how the
               | two sides interact, at least it was a bit of a struggle
               | for me, maybe / hopefully it got a bit better in the
               | meantime.
               | 
               | And thankfully LuaLaTex was ready enough at that time, I
               | can't imagine how bad it would've been to do this in pure
               | Tex ...
        
               | enriquto wrote:
               | Are you one of the authors of tikz graphdrawing?
        
               | nyir wrote:
               | Just a former student who participated in the first
               | version (let's say draft) of it, which had no really
               | interesting algorithms in it yet, just the overall graph
               | framework and integration with the rest of PGF/TikZ.
               | 
               | Really cool project though, one of the few that made it
               | outside of uni.
        
               | [deleted]
        
       | zero37z wrote:
       | It would be nice, if they add theme effect like a game called
       | Detroit become human
        
       | brasetvik wrote:
       | Big fan of graphviz.
       | 
       | Lots of interesting tools that use it being posted here, so
       | here's a toy of mine: https://github.com/alexbrasetvik/graphspec
       | 
       | I've used it mostly to mix edge+node definitions in comments in
       | asciidoc or code, and the non-nested nature makes it easy to
       | compose different sources of edges and nodes.
       | 
       | (It's just a POC. If you know of something similar that's more
       | actively developed, I'd be very interested)
        
         | abathur wrote:
         | I'm also interested in this (or something more actively-
         | developed), as it's the first time I've seen what looks like an
         | answer to a question I've had recently.
         | 
         | If it helps to know how someone else thinks about it: I've been
         | looking for a way to _compose_ or _import_ or _include_ a graph
         | or subgraph defined in one file into multiple other graphs.
         | I've started to assume I'll just need a preprocessor or
         | template engine.
         | 
         | In my case, I'm interested in the feasibility of building a
         | really big interactive chart, like a decision tree or
         | differential diagnosis chart, to help users discover
         | docs/examples/tools/tutorials etc. that can meet their needs or
         | fix their problems, and I suspect a single-file approach just
         | isn't going to scale well. (Composition/inclusion is a bit of
         | an MVP focus, I guess. I think it would also be nice to be able
         | to have a good way to generate versions of the graphs from
         | multiple perspectives--like 1. a diagnosis chart that helps
         | users identify a common formulation of their problem and its
         | most-canonical solution, 2. a graph that helps users figure out
         | what a command-line tool is used for by mapping each one to the
         | problems they solve, 3. a graph that helps users who've run
         | into trouble solving X with Y by mapping it to more known
         | solutions and showing additional context on the
         | pros/cons/limits of each.)
         | 
         | An aside: I noticed a TODO on your repo about supporting a
         | comment syntax. Your existing syntax is very close to
         | directives from reStructuredText (https://docutils.sourceforge.
         | io/docs/ref/rst/restructuredtex...). Since it's already a
         | Python project, I wonder if it makes sense to piggy-back on
         | docutils, or at least borrow the comment syntax (https://docuti
         | ls.sourceforge.io/docs/ref/rst/restructuredtex...).
        
       | siraben wrote:
       | Graphviz's syntax easy enough to programmatically generate,
       | here's the course dependencies for CS classes at my university,
       | for instance, generated by a Haskell program that scraped the
       | appropriate data.
       | 
       | https://i.imgur.com/OZarGSg.png
        
       | nikeee wrote:
       | Shameless plug: I created an online Graphviz/dot editor which is
       | powered by a language server that provides auto completion and
       | refactorings. It uses a WASM version of Graphviz to render the
       | graph. You can try it out here:
       | 
       | https://edotor.net
        
         | kstenerud wrote:
         | Looks cool, but either the default graph has incorrect
         | comments, or it's buggy on firefox. There were no lightbulbs,
         | and clicking on "a" did nothing.
        
         | sanjeetsuhag wrote:
         | That's a fantastic tool! I've been doing some work to create
         | some hierarchy diagrams and this is perfect.
        
       | DavidPeiffer wrote:
       | I love how quickly you can generate a large GraphViz diagram! In
       | a past job we had the "network drive of shame" (actually all 4 of
       | my internships had that). So many Excel files which had
       | dependencies which weren't documented at all.
       | 
       | I once made a script which would go through each subdirectory,
       | open every Excel file, and document all dependencies, and output
       | to a GraphViz diagram. This enabled me to move a file and know
       | which files would break, absolutely vital for making changes in
       | that environment.
       | 
       | It wasn't beautiful - VBA checking properties of tables, pivot
       | tables, examining embedded VBA code searching for the network
       | share URI - but it did work.
       | 
       | For safety, I copied 200 GB from the network drive locally. 6
       | months later the guy in IT was curious why imaging my replacement
       | machine took _so_ long.
       | 
       | --
       | 
       | Last week I documented how money moves around my various bank
       | accounts. I needed to make sure all the bills get paid even
       | though I'm switching banks. A quick GraphViz diagram is proving
       | to be really handy.
        
       | asdkhadsj wrote:
       | Can anyone recommend a resource for learning how to diagram?
       | 
       | Notably, I don't want to free-design directional relationships
       | that are counter intuitive to what people expect. Eg, if Service
       | A calls Service B, does the arrow go to Service B? What about the
       | response? I imagine there are a ton of little questions like this
       | and I'd like to learn to write what people expect to see.
        
         | mr_tristan wrote:
         | I'd actually start with Tufte:
         | https://www.edwardtufte.com/tufte/books_vdqi
         | 
         | There are standards like UML, but I've never found those to be
         | as useful to start with. It's best to treat this as a "design
         | problem": first, answer the question: "what am I
         | communicating".
         | 
         | Then, maybe look into conventions - but often you'll find less
         | need for one "master UML diagram" and instead use many, smaller
         | diagrams embedded within reference docs.
         | 
         | I feel like project reactor did a good job here:
         | https://projectreactor.io/docs/core/release/api/reactor/core...
         | 
         | Personally I'd like to see more related to inheritance, but
         | I'll take what I can get. The tooling can be a pain to embed
         | automatic diagrams in
        
         | mthoms wrote:
         | Perhaps https://plantuml.com/sequence-diagram ?
        
       | rakoo wrote:
       | The Zim wiki software has a plugin for graphviz (https://www.zim-
       | wiki.org/manual/Plugins/Diagram_Editor.html), where you can edit
       | your graph and see the results in real time. Very helpful if only
       | for this feature
        
       | GnarfGnarf wrote:
       | Can't find a Windows binary to download.
        
       | RBerenguel wrote:
       | I used graphviz as the main visualisation for bear-note-graph
       | [1], and it's super-easy to use programmmatically, and gives
       | decent-looking results even for large graphs. It is also pretty
       | customizable.
       | 
       | I have a WIP version now using D3, and that one has been harder
       | to manage (when the graph is too large you don't want to have it
       | animate the layout on the fly). If you are curious, I used the
       | same D3 code I have in the WIP to present a sitemap of my blog
       | [2]                   [1] https://github.com/rberenguel/bear-
       | note-graph         [2] https://mostlymaths.net/sitemap/
        
         | abathur wrote:
         | Curious what you think about something, since it seems like
         | you've been iterating on the challenge of a big interactive
         | graph lately.
         | 
         | I've been pondering building a big interactive chart, like a
         | decision tree or differential diagnosis chart, that maps
         | goals/needs/problems to docs/examples/tools (for the
         | Nix/NixOS/Nixpkgs ecosystem, but the basic concept applies to
         | any sprawling ecosystem where discovery is hard).
         | 
         | I recently stumbled on https://github.com/mermaid-js/mermaid,
         | which seems like it has an interaction model that could support
         | what I have in mind (minus the question of whether there are
         | performance cliffs that'd make it unsuitable).
         | 
         | If you considered mermaid while working on bear-note-graph,
         | could you share the conclusions you came to?
        
           | RBerenguel wrote:
           | I didn't check mermaid for bng, but had checked it before (I
           | like visual representations of knowledge, no matter what they
           | are for). Although I found it interesting, my gut feeling
           | here was that if my problem's solution (at that point it was
           | just out of curiosity) was going to be JS-based at some
           | point, I should go directly for D3 (I already had experience,
           | but not recent, with D3).
           | 
           | Mermaid uses D3 under the scenes, so depending on your
           | specifics it could be the best solution anyway, though.
           | Performance wise, I'd expect it to be OK (D3 is pretty fast
           | in most cases) although if there are any issues down the
           | road, fixing them from such a high level library as mermaid
           | could be daunting (it's "easier" to move down from D3 to
           | paper.js or g.js or any other high performance canvas
           | renderer if the case arises).
        
       | braythwayt wrote:
       | I ended up with a different tool, but I was uncomfortable using
       | drawing apps for diagrams, and only rarely included them in my
       | blog until I could use text to define them.
       | 
       | I'm all-in on Markdown + Github for writing, so working with
       | text-driven diagrams is a natural fit.
        
         | prepend wrote:
         | What tool did you use? I've been using mermaid and its markdown
         | plug-ins and like it quite a bit, but am always looking for new
         | ways.
        
           | hugozap wrote:
           | I recently wrote about using Markdown with Diagram codes
           | https://blog.diagram.codes/posts/markdown-intro/ (I'm the
           | creator) it's a complementary desktop tool with (web version
           | is limited and free, desktop is paid)
           | 
           | I love text based tools but wanted to create something that
           | users without technical backgrounds can use, I feel that a
           | lot of existing tools are too complex for casual users.
        
       | rcarmo wrote:
       | As much as I like Graphviz (and I've been using it for ages) I
       | keep looking for an equivalent with two features:
       | 
       | - Nicer, more modern looks (the original is too... LaTeX-y for my
       | tastes)
       | 
       | - A different layout engine that uses straight arrows and 90
       | degree turns
       | 
       | So far I haven't been able to find any good replacements,
       | although a few JS libraries come reasonably close.
        
         | [deleted]
        
         | prepend wrote:
         | I was thinking that a d3 implementation would help with this,
         | except for the 90 degree, and found a project [0].
         | 
         | It's not a force directed graph, but does seem to me to look
         | better. And since the output is javascript it can be styled and
         | formatted as you like it.
         | 
         | [0] https://github.com/magjac/d3-graphviz
        
         | leejoramo wrote:
         | It has been over a decade since I did this regularly, but I
         | would import my Graphviz files into the excellent OmniGraffle
         | (macOS) to provide what ever styling I wanted, and use a
         | variety of highly configurable layout engines. Almost certain
         | that the "straight arrows and 90 degree turns" layout is in
         | there.
         | 
         | OmniGraffle is one of the best commercial software packages
         | every developed. Well worth a look if you are on macOS
        
         | ribasushi wrote:
         | > A different layout engine that uses straight arrows and 90
         | degree turns
         | 
         | It's not a property of the engine but of the graph itself:
         | 
         | http://www.graphviz.org/doc/info/attrs.html#d:splines
         | 
         | https://stackoverflow.com/a/9055243
        
           | [deleted]
        
         | withinboredom wrote:
         | I use mermaid when I need a graph in markdown along with the
         | mermaid extension to render it inline.
        
         | RobinL wrote:
         | Possibly Elk? - there's a simple start notebook here:
         | https://observablehq.com/@tmcw/elk and example of more complex
         | output here: https://observablehq.com/@observablehq/notebook-
         | visualizer-e...
        
         | hugozap wrote:
         | I've been working on diagram.codes, it's not a replacement for
         | Graphviz as my goal is to have a self contained tool that is
         | friendly to non technical users (so flexibility is sacrificed
         | for some diagrams), you may find it useful.
        
         | [deleted]
        
         | cm2187 wrote:
         | Also I think graphviz is a great tool when you want to generate
         | some diagrams quickly and don't care too much about the design.
         | If you have a precise idea of how it should look, it is
         | possible to force it to look that way but it becomes a lot of
         | work (with a complex logic of clusters, ranks, groups, etc).
        
           | afterburner wrote:
           | My main complaint.
        
         | enriquto wrote:
         | > Nicer, more modern looks (the original is too... LaTeX-y for
         | my tastes)
         | 
         | Can you explain what do you mean by that, exactly? I think the
         | looks of graphviz graphs are exceedingly beautiful and I cannot
         | imagine a better looking way of drawing graphs (other than some
         | minor technical issues with font kerning).
        
           | bvrmn wrote:
           | My top graphviz issues.
           | 
           | * Automatic edge placement can lead to visually ambiguous
           | results and it is very hard to tweak it.
           | 
           | * Edge title placement engine is sort of naive and best
           | solution is to not use edge titles at all.
           | 
           | * Bogus text wrapping. Text can leak outside of the node box.
           | 
           | * Default margins and padding lead to visual clutter.
        
             | weinzierl wrote:
             | I was about to summarize my pain points but you covered
             | them all and expressed them better than I could. What I
             | often find difficult is to reliably prevent overlap, I
             | would subsume that under you last point about margins and
             | paddings.
        
       | ngneer wrote:
       | I have used Graphviz successfully to communicate with other
       | software engineers about non-trivial state machines in the
       | program. Specifically, C# Stateless allows exporting DOT files.
       | Does anyone know if graphing nested nodes has already been
       | solved?
        
       | stilisstuk wrote:
       | Dokuwiki has a very usefull graphviz plugin.
       | https://www.dokuwiki.org/plugin:graphviz
        
       | roenxi wrote:
       | Graphviz is almost deceptively bad. If I see a graph in a book; I
       | expect it was made in TikZ.
       | 
       | TikZ isn't fun, but at least it has the flexibility to get a
       | great looking image at the end of the process. The theoretical
       | simplicity advantages of Graphviz usually get worn down by the
       | fact that the diagrams look bad. Use PowerPoint, and if code is
       | needed bite the bullet and struggle through TikZ.
        
       | _ZeD_ wrote:
       | chime in just to add that I discovered grapviz using the
       | venerable doxygen[0] tool and the availability of the calling
       | graph
       | 
       | [0] https://www.doxygen.nl/index.html
        
       | lihaoyi wrote:
       | I use Graphviz throughout my book https://www.handsonscala.com to
       | render diagrams. I honestly think it looks pretty good:
       | 
       | - Dependency graph between chapters in the book:
       | https://www.handsonscala.com/chapter-1-hands-on-scala.html#s...
       | 
       | - Tree-shaped `Vector` with structural sharing:
       | https://www.handsonscala.com/chapter-4-scala-collections.htm...
       | 
       | - Singly-linked `List` with shared tails:
       | https://www.handsonscala.com/chapter-4-scala-collections.htm...
       | 
       | - Collections class inheritance hierarchy:
       | https://www.handsonscala.com/chapter-4-scala-collections.htm...
       | 
       | The book's home page above also has a nice actor-message-passing
       | diagram rendered with Graphviz (might need to scroll down a bit).
       | 
       | My only preferred change to the default style is `node [shape=box
       | width=0 height=0]`. Otherwise the nodes have tons of white space
       | that makes the graph a lot more bulky than it really needs to be.
       | 
       | The automated layout engine gives me exactly what I want 90% of
       | the time, and the last 10% is usually isn't too hard to coax into
       | looking good via `rank=same`s or `constraint=false` or similar.
       | In particular, the examples above required zero coaxing: I just
       | specified the graph structure, and that's the layout that popped
       | out.
       | 
       | I ended up doing a lot of prototyping in
       | http://www.webgraphviz.com/ and before pasting the final DOT into
       | my markdown file. IntelliJ has a Graphviz/DOT plugin, but it's
       | not as seamless as using that web editor. The graphs definitely
       | end up looking a lot more consistent than anything I could come
       | up with dragging boxes around in microsoft office or google docs.
       | 
       | The graphs don't look fancy and design-y, but they're simple and
       | straightforward and get the point across clearly.
        
         | kragen wrote:
         | Those all look great! I'm jealous! I think the green arrows do
         | look fancy and design-y.
         | 
         | I've sometimes been able to get surprisingly flashy results
         | with cluster subgraphs with background colors.
        
       | wodenokoto wrote:
       | I'd like to write some scripts that can take some of my code and
       | produce a graph of it.
       | 
       | Things I'd like is for example to draw a GCP cloud build file, or
       | something like that.
       | 
       | What would be a good intermediate format for this? I'll read an
       | xml or yaml file into a python list of dicts and then loop
       | through it and write ... Graphviz? Mermaid? Tikz?
       | 
       | What do you guys recommend?
        
         | q3k wrote:
         | Using graphviz for visualizing these things is fast and easy.
         | print('digraph foo {')         # adj_list contains tuples of
         | (parent node name, child node name)         for parent, child
         | in adj_list:             print(f'{parent} -> {child}')
         | print('}')
         | 
         | Redirect that to a file and view with `xdot`, done.
         | 
         | I've done exactly this a few days ago to visualize the Linux
         | build graph:
         | https://q3k.org/u/73839114a0e5ee65002029892a069dd1b645a8f9f0...
        
       | iso-8859-1 wrote:
       | Used Viz.js (Graphviz compiled to JavaScript) for an animated
       | B-Tree visualization, and it works great:
       | 
       | http://ysangkok.github.io/js-clrs-btree/btree.html#{%22actio...
        
       | kragen wrote:
       | A couple of important tips that the article omits:
       | 
       | 1. For manual editing, dot -Tx11 foo.dot displays the graph in a
       | window _and updates it automatically whenever you save_. So you
       | can have an editor window open and the dot window and see the
       | results of every tweak. For automatically generated graphs, this
       | provides you with a window that you can update by overwriting a
       | file with a new graph description.
       | 
       | 2. Although HTML nodes are more versatile, shape=record is much
       | easier, and sufficient for a pretty wide range of diagrams.
       | 
       | For doing quick stuff by hand if you don't have Graphviz
       | installed, or if you're stuck on a Mac without X-Windows, there's
       | https://graphviz.christine.website/. I like Graphviz a lot; as
       | other people point out, TikZ is capable of a wider range of
       | graphics, and also you can write programs to generate graphs in
       | TikZ. But Graphviz is often enough.
       | 
       | A really simple graph like
       | https://graphviz.christine.website/#digraph%20G%20%7Ba-%3E%7...
       | is sometimes good enough without further tweaking, but for,
       | _e.g._ , the top diagram in
       | https://github.com/kragen/dumpulse#dumpulse-an-embeddable-du...,
       | you usually have to tweak stuff a bit.
        
         | egwor wrote:
         | I used xdot in Ubuntu earlier this week and it crashed my Gnome
         | session. Beware!
        
         | m000 wrote:
         | 3. dot pairs nicely with m4 [1] and a Makefile. Without m4,
         | it's a pain to apply a uniform style on groups of nodes.
         | 
         | [1] https://en.wikipedia.org/wiki/M4_(computer_language)
        
           | kragen wrote:
           | You can put the group of nodes in a subgraph and apply the
           | uniform style to the subgraph. In https://gitlab.com/kragen/b
           | ubbleos/-/tree/master/yeso#callin... I did that for example
           | as follows in
           | https://gitlab.com/kragen/bubbleos/-/blob/master/yeso/api-
           | ty...:                       subgraph types {
           | node [shape=square];                     subgraph ints {
           | node [label=int];                             int bool fd
           | u32in die stride;                     }
           | long int s32 u8 u32 -> ypix ywin;                     ...
           | 
           | Its expressivity is limited, since it depends on a
           | hierarchical classification of your nodes and arcs that
           | doesn't always eliminate all duplication, but it's usually
           | enough to manually style the nodes the way I want without too
           | much hassle. Because "types" and "ints" aren't "clusters",
           | they don't affect the layout. (If you do want to use
           | clusters, that can make this approach more difficult.)dnl
           | 
           | I haven't ever been quite desperate enough to use m4 to
           | generate Graphviz files, although clearly it is a good fit.
           | My experiences with m4 are more in the nature of getting way
           | too much rope to hang myself with and then having a terrible
           | time debugging. I wrote an HTML-generating macro language in
           | m4 in 1994 and have never stopped regretting it.dnl
           | 
           | I do agree about the Makefile. In Dumpulse I used the
           | following Makefile rule:                   %.png: %.dot
           | dot -Tpng < $< > $@
           | 
           | That way I can rebuild the README diagrams (if outdated) just
           | by listing "diagram.png heartbeat.png health-report.png" as
           | dependencies of the "all" target.
           | https://github.com/kragen/dumpulse/blob/master/Makefile
        
             | m000 wrote:
             | You only need a couple of line to plug in automatic m4
             | preprocessing in Makefile. And perhaps add a .SECONDARY
             | line if you are debugging to prevent the intermediate .dot
             | files from being deleted.                   %.dot: %.dot.m4
             | m4 < $< > $@
             | 
             | I use m4 to implement something akin to css classes, only a
             | bit more powerful because you can do pseudo-subclassing.
             | E.g.                   define(`base_node', `width=1.75,
             | height=1.0, fontname="Menlo", fontsize=13')
             | define(`file',`base_node, shape=note')
             | define(`directory',`base_node, shape=folder')
             | define(`important', `fontname="Menlo Italic"')
             | ...              tarball [file, label="foo.tar"];
             | vardir  [directory, label="/var"];         etcdir
             | [directory, important, label="/etc"];
        
               | kragen wrote:
               | Right! That kind of crosscutting thing is tricky to do
               | with the hierarchical nature of subgraphs. Without some
               | kind of macro preprocessor you'd end up doing something
               | like                   node [width=1.75, height=1.0,
               | fontname="Menlo"];              subgraph files {
               | node [shape=note];             tarball [label="foo.tar"];
               | subgraph importantfiles {                 node
               | [fontname="Menlo Italic"];                 ...
               | }         }              subgraph dirs {             node
               | [shape=folder];             vardir [label="/var"];
               | subgraph importantdirs {                 node
               | [fontname="Menlo Italic"];                 etcdir
               | [label="/etc"];             }         }
               | 
               | This obviously has the drawback that if you change the
               | importance font, you have to change it twice instead of
               | once, and you might forget. And clearly there are cases
               | where that kind of duplication is a bigger problem than
               | the difficulties with m4.
        
       | [deleted]
        
       | ColinWright wrote:
       | I use GraphViz a lot. Here it the Twitter conversation that
       | ensued when I asked a question about the use of Group Theory "In
       | Real Life":
       | 
       | https://www.solipsys.co.uk/Chitter/GroupTheory_IRL.svg
        
         | gilleain wrote:
         | Ha nice visualisation. Would be amazing if this was available
         | for more chat systems where conversations branch like this.
         | 
         | Also, as a side note its funny that there is a lot of
         | discussion (including Baez!) about theoretical maths, and one
         | lone tweet about molecular symmetry.
        
           | ColinWright wrote:
           | I have the same system for Mastodon ... works well to help
           | visualise the complex discussions that sometimes happen.
        
         | chrisweekly wrote:
         | haha, that is awesome. "show don't tell", "the medium is the
         | message"... and wow, what a great use case! This tree UI for
         | rendering multi-threaded conversations would be a great feature
         | in slack or twitter. Bravo -- and thanks for sharing! :)
        
         | Lunatic666 wrote:
         | I'm using it at work, e.g. to visualize state machines. It
         | makes it a lot easier to discuss it with business people. In
         | Java there is a great library which translates code into
         | graphviz markup: guru.nidi/graphviz-java
        
           | h91wka wrote:
           | I don't want to diminish importance of graphviz, but PlantUML
           | is better suited for visualizing state machines, message
           | sequence diagrams and whatnot.
        
             | username3 wrote:
             | Does PlantUML do statecharts?
        
               | seidleroni wrote:
               | Yes. https://plantuml.com/state-diagram
        
             | xamde wrote:
             | PlantUML is a good syntax. Under the hood... it renders via
             | GraphViz
        
               | baq wrote:
               | which is exactly why it's great! :)
        
       | bvrmn wrote:
       | I've been trying to use graphviz for many years. Idea of storing
       | graph data as text with presentation hints is very appealing. But
       | simple diagrams can be made in corresponding software (draw.io)
       | way too faster. For complex diagrams I had to constantly fight
       | with layout engine and place too many hints.
        
       | jgalt212 wrote:
       | While the stylings on graphviz are somewhat limited, as others
       | have indicated, I have yet to find a modern js based in browser
       | library makes the layouts as aesthetically balanced right out of
       | the box as much as graphiz/dot does.
        
       | bregma wrote:
       | Fun hidden use of graphviz: if you use GCC's <regex> in your
       | code, try defining _GLIBCXX_DEBUG and call the member function
       | _M_dot() on your regex objects.
       | 
       | We left that in when developing the <regex> module because it
       | turned out to be very useful for debugging regular expressions,
       | not just the regex implementation itself.
        
         | shpongled wrote:
         | That's cool! Every time I end up implementing some kind of
         | graph structure, writing a simple dot output method is one of
         | the first things I do. It's incredibly useful for debugging
         | stuff, and only takes a couple minutes to put together.
        
       | edparcell wrote:
       | I'm a big fan of Graphviz. My old team created a library called
       | Loman, which we open-sourced, which uses DAGs to represent
       | calculations. Each node represents a part of the calculation and
       | contains a value, similar to a cell in an spreadsheet, and Loman
       | tracks what is stale as you update inputs. Loman includes built
       | in support for creating diagrams using Graphviz. In our quant
       | research we have found that invaluable when revisiting old code,
       | as it allows you to quickly see the structure and meaning of
       | graphs with hundreds of nodes, containing thousands of lines of
       | code.
       | 
       | We've found it quite useful for quant research, and in production
       | it works nicely because you can serialize entire computation
       | graph which gives an easy way to diagnose what failed and why in
       | hundreds of interdependent computations. It's also useful for
       | real-time displays, where you can bind market and UI inputs to
       | nodes and calculated nodes back to the UI - some things you want
       | to recalculate frequently, whereas some are slow and need to
       | happen infrequently in the background.
       | 
       | [1] Github:
       | https://github.com/janushendersonassetallocation/loman
       | 
       | [2] Docs: https://loman.readthedocs.io/en/latest/
       | 
       | [3] Examples:
       | https://github.com/janushendersonassetallocation/loman/tree/...
        
       | jcpst wrote:
       | Graphviz has improved my development workflow.
       | 
       | I use dot notation, and in spacemacs I can have a buffer with the
       | the png file that reloads on save.
       | 
       | When debugging distributed enterprise systems, being able to type
       | in the workflow as you go and then share your findings is
       | awesome.
        
       | speeder wrote:
       | I wasted in my current project too many time trying to make GViz
       | behave. It is a tool that has lots of potential but has some
       | insanely obvious flaws, I literally wasted 8 work days just
       | trying to make a small planning document, because Graphviz won't
       | cooperate unless you start to pile up attributes one after the
       | other in Byzantine hacks.
       | 
       | 1. Why the "cluster" word is needed on subgraph names? I am not
       | making my project in English.
       | 
       | 2. Why I can't move a whole subgraph to the "end" or "start" ?
       | GViz attempts to make all graphs compact (regardless your
       | settings) and thus tends to shove subgraphs in "random" places.
       | 
       | 3. Why nodes sometimes leave their subgraph and end on another
       | one? Even when the end result makes no sense? (My graph ended
       | with several places where "a" and "c" is on one cluster and "b"
       | is in a another, with lots of "U" shaped edges connecting then)
       | 
       | The official website has a bunch of broken links.
       | 
       | "Weight" attribute often is ignored...
       | 
       | And the list goes on.
       | 
       | Stack overflow is full of bizarre solutions to Graphviz behavior,
       | for example minimum edge length (that for some reason is in
       | inches despite most of the planet using mm)
        
       | zengid wrote:
       | I wonder if this could be used on windows via the Windows
       | Subsystem for Linux?
        
       | wmu wrote:
       | Really nice, well written introduction. Graphviz is a cool tool,
       | we used this when debugging some graph-related algorithms.
        
       | cm2187 wrote:
       | Has anyone seen a library to draw genealogy trees
       | programatically? Every time I look at it, it looks like an
       | impossible problem.
        
         | op03 wrote:
         | https://github.com/fredatgithub/FamilyShow
        
       | zwischenzug wrote:
       | Another plug: I wrote about using Graphviz for representing
       | project management dependencies in code and collaborating with my
       | team here:
       | 
       | https://zwischenzugs.com/2017/12/18/project-management-as-co...
       | 
       | The OP page is a really great intro, I could have used it as a
       | reference when I was doing that work.
        
       | hmottestad wrote:
       | I love generating DOT from my Java programs. I recently
       | implemented a query explainer that would output the query plan as
       | DOT.
       | 
       | Btw. For those working with DOT I've always found it great to be
       | able to copy-paste it right onto a webpage and see the results.
       | My current favourite tool:
       | https://dreampuf.github.io/GraphvizOnline/
        
       ___________________________________________________________________
       (page generated 2020-06-10 23:00 UTC)