My favorite graphing tool – Graphviz

My favorite graphing tool – Graphviz

I used to create many graphs, usually the kind of dependency/hierarchy (see the previous post about Programming paradigms in JavaScript).

A long time ago I discovered a perfect tool for a developer to create and maintain various graphs – Graphviz. You can download it and use offline, but there are also online interpreters for quick experiments, for example:

The last one is especially interesting, as it contains numerous interesting samples.

Rules

Graphs can be created extremely simply with text (and therefore they are perfect for scripting).

Just remember about 3 simple rules:

  1. the graph starts with the line digraph G { and ends with }
  2. add <from> -> <to> in next lines and a connection between <from> and <to> nodes will be created. You can create more links at once, e.g. A -> B -> C -> D
  3. the node identifiers I listed in the previous point can contain letters and some characters, but definitely not spaces. This can be corrected by using labels:
SomeNode -> AnotherNode
SomeNode [label="Some Node"]
AnotherNode [label="Another Node"]

There are many more options for formatting nodes and edges and for adjusting layout. Fortunately, there is good documentation on the project’s website.

Example

I’ll show how I created the graph for Programming paradigms in JavaScript post:

Code:

Plain Text

Leave a Reply

avatar
  Subscribe  
Notify of