Skip to content

Instantly share code, notes, and snippets.

@Mic92
Last active December 31, 2015 01:59
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 Mic92/7917976 to your computer and use it in GitHub Desktop.
Save Mic92/7917976 to your computer and use it in GitHub Desktop.
// 1. graphviz installieren.
// $ pacman -S graphviz
// oder
// $ brew install graphviz
// 2. Bild rendern
// $ dot -Tpdf graph.dot > graph.pdf
digraph heron {
// Standards für Kanten und Knoten
edge [arrowhead=odot]
graph [overlap=scale]
subgraph {
edge [weight=3];
// Dies sind die einzelnen Berechnungszustände
// Operationen müssen an diesem Zuständen ausgerichtet werden
// minlen=4 sorgt für etwas mehr Abstand, was häufig zu lesbareren Graphen
// führt.
C0 -> C1 -> C2 -> C3 [minlen=4]
}
// Es gibt Nodes (Knoten) ...
// (label setzt optional einen anderen Titel)
mem_0 [label="mem[0]"]
// ... und Edges (Kanten)
mem_0_plus_1 [label="+"]
1 -> mem_0_plus_1 // Knoten müssen nicht seperat definiert werden
mem_0 -> mem_0_plus_1
{ rank=same; C0; mem_0_plus_1} // C0 und 1_plus_mem_0 sind nun auf der selben Höhe.
// Ein Vergleich
lte_2 [label=">"]
mem_0_plus_1 -> lte_2
2 -> lte_2
{ rank=same; C1; lte_2}
// Fall-Unterscheidung könnte so aussehen.
lte_2 -> "..." [label="True", style=dotted]
lte_2 -> "...." [label="False", style=dotted]
{ rank=same; C2; "....", "..."}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment