Skip to content

Instantly share code, notes, and snippets.

@rodw
Created March 8, 2014 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodw/122fc58b0597249ece4b to your computer and use it in GitHub Desktop.
Save rodw/122fc58b0597249ece4b to your computer and use it in GitHub Desktop.
Graphviz DOT file that generates the image @reinh is looking for in the tweet at https://twitter.com/ReinH/status/440955529494413313 Renders as http://ow.ly/i/4PO8v
//
// Run this graph definition through the dot rendering engine.
//
// E.g.:
// dot -Tpng pentagonal-graph-for-reinh.gv -o image.png
// or
// dot -Txlib pentagonal-graph-for-reinh.gv
//
// Also note that if you don't care about the exact orientation,
// the "out of the box" rendering with the circo engine is pretty
// much exactly what you're looking for.
//
digraph {
// Use straight lines rather than curved:
splines=false
// Tweak the width of the graph by setting the distance
// between nodes of the same rank:
nodesep=0.4
// Use text-only nodes:
node [shape=plaintext]
// Create the five (visible) nodes:
a1 [label="a"]
b1 [label="b"]
b2 [label="b"]
a2 [label="a"]
c
// ...and the edges between them:
a1 -> b1
a1 -> c
a1 -> a2
b1 -> b2 [weight=10]
b2 -> a2
c -> a2
a1 -> b2
b1 -> a2
// (Note that setting "weight=10" keeps the b1->b2 edge
// short and straight.)
// Now we create some hidden nodes and edges to
// tweak the layout.
// Set the node and edge styles to be invisible:
node [shape=point height=0 width=0]
edge [style=invis]
// (Note that you can change "invis" to "dotted" to see
// what's happening here.)
// Create a couple of dummy nodes (below node a1 and
// above node c) and ensure they are on the same row
// (rank) as node b1:
{ rank=same; b1; belowa1; abovec; }
// Create a couple more dummy nodes, on the same rank
// as node b2:
{ rank=same; b2; abovea2; belowc; }
// Create some invisble edges between the real nodes
// and the dummy nodes to influence placement:
a1 -> abovec -> c -> belowc -> a2
a1 -> belowa1 -> abovea2 -> a2
b1 -> belowa1 -> c
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment