Help:Graphs

From RBOSE
Jump to: navigation, search

The tool "Graphviz" allows to produce diagrams on the fly, which can be easily and collaboratively developed. All changes are recorded by the wiki revision mechanism, so you can find out how specific idea evolved with time. The syntax is very simple and could be also produced with external, automated tools and exported to any other system directly from wiki page. The optimization function will take care about location of the data on the diagram and all you need to do is write down the relations which you would like to illustrate.



TODO

<tasks> [!] Graphviz wiki extensions has been updated. Please help update information on this page by referring to http://edutechwiki.unige.ch/en/Graphviz (anybody) </tasks>


Syntax

All code for a graph has to be placed between the tags <graphviz render=dot> and </graphviz>. The render parameter is optional, but allows you to choose among several different renderers listed below. The default one is dot and will be used if render parameter is not supplied.


Renderers

  • dot - "hierarchical" or layered drawings of directed graphs. The layout algorithm aims edges in the same direction (top to bottom, or left to right) and then attempts to avoid edge crossings and reduce edge length.
  • neato - "spring model" layouts. Neato attempts to minimize a global energy function, which is equivalent to statistical multi-dimensional scaling. The solution is achieved using stress majorization, though the older Kamada-Kawai algorithm, using steepest descent, is also available. fdp implements the Fruchterman-Reingold heuristic including a multigrid solver that handles larger graphs and clustered undirected graphs.
  • fdp - "spring model" layouts similar to those of neato, but does this by reducing forces rather than working with energy. Fdp implements the Fruchterman-Reingold heuristic including a multigrid solver that handles larger graphs and clustered undirected graphs.
  • twopi - "radial" layouts, after Graham Wills 97. The nodes are placed on concentric circles depending their distance from a given root node.


(Please add more explanations of the most useful tags and parameters)

Examples

<graphviz> digraph A { A -> B } </graphviz>

<graphviz>
digraph A {
A -> B
}
</graphviz>

<graphviz> digraph B { rankdir="LR"; Resources -> Tools Resources -> People Resources -> Energy Resources -> Time Resources -> Methods Resources -> Place Resources -> Materials Tools -> Creation People -> Creation Energy -> Creation Time -> Creation Methods -> Creation Place -> Creation Materials -> Creation } </graphviz>

<graphviz>
digraph B {
rankdir="LR";
Resources -> Tools
Resources -> People
Resources -> Energy
Resources -> Time
Resources -> Methods
Resources -> Place
Resources -> Materials

Tools -> Creation
People -> Creation
Energy -> Creation
Time -> Creation
Methods -> Creation
Place -> Creation
Materials -> Creation
}
</graphviz>

<graphviz> digraph finite_state_machine { rankdir=LR; size="8,5" node [shape = doublecircle]; LR_0 LR_3 LR_4 LR_8; node [shape = circle]; LR_0 -> LR_2 [ label = "SS(B)" ]; LR_0 -> LR_1 [ label = "SS(S)" ]; LR_1 -> LR_3 [ label = "S($end)" ]; LR_2 -> LR_6 [ label = "SS(b)" ]; LR_2 -> LR_5 [ label = "SS(a)" ]; LR_2 -> LR_4 [ label = "S(A)" ]; LR_5 -> LR_7 [ label = "S(b)" ]; LR_5 -> LR_5 [ label = "S(a)" ]; LR_6 -> LR_6 [ label = "S(b)" ]; LR_6 -> LR_5 [ label = "S(a)" ]; LR_7 -> LR_8 [ label = "S(b)" ]; LR_7 -> LR_5 [ label = "S(a)" ]; LR_8 -> LR_6 [ label = "S(b)" ]; LR_8 -> LR_5 [ label = "S(a)" ]; } </graphviz>

<graphviz>
digraph finite_state_machine {
	rankdir=LR;
	size="8,5"
	node [shape = doublecircle]; LR_0 LR_3 LR_4 LR_8;
	node [shape = circle];
	LR_0 -> LR_2 [ label = "SS(B)" ];
	LR_0 -> LR_1 [ label = "SS(S)" ];
	LR_1 -> LR_3 [ label = "S($end)" ];
	LR_2 -> LR_6 [ label = "SS(b)" ];
	LR_2 -> LR_5 [ label = "SS(a)" ];
	LR_2 -> LR_4 [ label = "S(A)" ];
	LR_5 -> LR_7 [ label = "S(b)" ];
	LR_5 -> LR_5 [ label = "S(a)" ];
	LR_6 -> LR_6 [ label = "S(b)" ];
	LR_6 -> LR_5 [ label = "S(a)" ];
	LR_7 -> LR_8 [ label = "S(b)" ];
	LR_7 -> LR_5 [ label = "S(a)" ];
	LR_8 -> LR_6 [ label = "S(b)" ];
	LR_8 -> LR_5 [ label = "S(a)" ];
}
</graphviz>

<graphviz> digraph unix { size="6,6"; node [color=lightblue2, style=filled]; "5th Edition" -> "6th Edition"; "5th Edition" -> "PWB 1.0"; "6th Edition" -> "LSX"; "6th Edition" -> "1 BSD"; "6th Edition" -> "Mini Unix"; "6th Edition" -> "Wollongong"; "6th Edition" -> "Interdata"; "Interdata" -> "Unix/TS 3.0"; "Interdata" -> "PWB 2.0"; "Interdata" -> "7th Edition"; "7th Edition" -> "8th Edition"; "7th Edition" -> "32V"; "7th Edition" -> "V7M"; "7th Edition" -> "Ultrix-11"; "7th Edition" -> "Xenix"; "7th Edition" -> "UniPlus+"; "V7M" -> "Ultrix-11"; "8th Edition" -> "9th Edition"; "1 BSD" -> "2 BSD"; "2 BSD" -> "2.8 BSD"; "2.8 BSD" -> "Ultrix-11"; "2.8 BSD" -> "2.9 BSD"; "32V" -> "3 BSD"; "3 BSD" -> "4 BSD"; "4 BSD" -> "4.1 BSD"; "4.1 BSD" -> "4.2 BSD"; "4.1 BSD" -> "2.8 BSD"; "4.1 BSD" -> "8th Edition"; "4.2 BSD" -> "4.3 BSD"; "4.2 BSD" -> "Ultrix-32"; "PWB 1.0" -> "PWB 1.2"; "PWB 1.0" -> "USG 1.0"; "PWB 1.2" -> "PWB 2.0"; "USG 1.0" -> "CB Unix 1"; "USG 1.0" -> "USG 2.0"; "CB Unix 1" -> "CB Unix 2"; "CB Unix 2" -> "CB Unix 3"; "CB Unix 3" -> "Unix/TS++"; "CB Unix 3" -> "PDP-11 Sys V"; "USG 2.0" -> "USG 3.0"; "USG 3.0" -> "Unix/TS 3.0"; "PWB 2.0" -> "Unix/TS 3.0"; "Unix/TS 1.0" -> "Unix/TS 3.0"; "Unix/TS 3.0" -> "TS 4.0"; "Unix/TS++" -> "TS 4.0"; "CB Unix 3" -> "TS 4.0"; "TS 4.0" -> "System V.0"; "System V.0" -> "System V.2"; "System V.2" -> "System V.3"; } </graphviz>

<graphviz>
digraph unix {
	size="6,6";
	node [color=lightblue2, style=filled];
	"5th Edition" -> "6th Edition";
	"5th Edition" -> "PWB 1.0";
	"6th Edition" -> "LSX";
	"6th Edition" -> "1 BSD";
	"6th Edition" -> "Mini Unix";
	"6th Edition" -> "Wollongong";
	"6th Edition" -> "Interdata";
	"Interdata" -> "Unix/TS 3.0";
	"Interdata" -> "PWB 2.0";
	"Interdata" -> "7th Edition";
	"7th Edition" -> "8th Edition";
	"7th Edition" -> "32V";
	"7th Edition" -> "V7M";
	"7th Edition" -> "Ultrix-11";
	"7th Edition" -> "Xenix";
	"7th Edition" -> "UniPlus+";
	"V7M" -> "Ultrix-11";
	"8th Edition" -> "9th Edition";
	"1 BSD" -> "2 BSD";
	"2 BSD" -> "2.8 BSD";
	"2.8 BSD" -> "Ultrix-11";
	"2.8 BSD" -> "2.9 BSD";
	"32V" -> "3 BSD";
	"3 BSD" -> "4 BSD";
	"4 BSD" -> "4.1 BSD";
	"4.1 BSD" -> "4.2 BSD";
	"4.1 BSD" -> "2.8 BSD";
	"4.1 BSD" -> "8th Edition";
	"4.2 BSD" -> "4.3 BSD";
	"4.2 BSD" -> "Ultrix-32";
	"PWB 1.0" -> "PWB 1.2";
	"PWB 1.0" -> "USG 1.0";
	"PWB 1.2" -> "PWB 2.0";
	"USG 1.0" -> "CB Unix 1";
	"USG 1.0" -> "USG 2.0";
	"CB Unix 1" -> "CB Unix 2";
	"CB Unix 2" -> "CB Unix 3";
	"CB Unix 3" -> "Unix/TS++";
	"CB Unix 3" -> "PDP-11 Sys V";
	"USG 2.0" -> "USG 3.0";
	"USG 3.0" -> "Unix/TS 3.0";
	"PWB 2.0" -> "Unix/TS 3.0";
	"Unix/TS 1.0" -> "Unix/TS 3.0";
	"Unix/TS 3.0" -> "TS 4.0";
	"Unix/TS++" -> "TS 4.0";
	"CB Unix 3" -> "TS 4.0";
	"TS 4.0" -> "System V.0";
	"System V.0" -> "System V.2";
	"System V.2" -> "System V.3";
}
</graphviz>

<graphviz> digraph E { size="7,7" graph [ rankdir = "LR" ]; node [ fontsize = "16" shape = "ellipse" ]; edge [ ]; "node0" [ label = "<f0> 0x10ba8| <f1>" shape = "record" ]; "node1" [ label = "<f0> 0xf7fc4380| <f1> | <f2> |-1" shape = "record" ]; "node2" [ label = "<f0> 0xf7fc44b8| | |2" shape = "record" ]; "node3" [ label = "<f0> 3.43322790286038071e-06|44.79998779296875|0" shape = "record" ]; "node4" [ label = "<f0> 0xf7fc4380| <f1> | <f2> |2" shape = "record" ]; "node5" [ label = "<f0> (nil)| | |-1" shape = "record" ]; "node6" [ label = "<f0> 0xf7fc4380| <f1> | <f2> |1" shape = "record" ]; "node7" [ label = "<f0> 0xf7fc4380| <f1> | <f2> |2" shape = "record" ]; "node8" [ label = "<f0> (nil)| | |-1" shape = "record" ]; "node9" [ label = "<f0> (nil)| | |-1" shape = "record" ]; "node10" [ label = "<f0> (nil)| <f1> | <f2> |-1" shape = "record" ]; "node11" [ label = "<f0> (nil)| <f1> | <f2> |-1" shape = "record" ]; "node12" [ label = "<f0> 0xf7fc43e0| | |1" shape = "record" ]; "node0":f0 -> "node1":f0 [ id = 0 ]; "node0":f1 -> "node2":f0 [ id = 1 ]; "node1":f0 -> "node3":f0 [ id = 2 ]; "node1":f1 -> "node4":f0 [ id = 3 ]; "node1":f2 -> "node5":f0 [ id = 4 ]; "node4":f0 -> "node3":f0 [ id = 5 ]; "node4":f1 -> "node6":f0 [ id = 6 ]; "node4":f2 -> "node10":f0 [ id = 7 ]; "node6":f0 -> "node3":f0 [ id = 8 ]; "node6":f1 -> "node7":f0 [ id = 9 ]; "node6":f2 -> "node9":f0 [ id = 10 ]; "node7":f0 -> "node3":f0 [ id = 11 ]; "node7":f1 -> "node1":f0 [ id = 12 ]; "node7":f2 -> "node8":f0 [ id = 13 ]; "node10":f1 -> "node11":f0 [ id = 14 ]; "node10":f2 -> "node12":f0 [ id = 15 ]; "node11":f2 -> "node1":f0 [ id = 16 ]; } </graphviz>

<graphviz>
digraph E {
size="7,7"
graph [
rankdir = "LR"
];
node [
fontsize = "16"
shape = "ellipse"
];
edge [
];
"node0" [
label = "<f0> 0x10ba8| <f1>"
shape = "record"
];
"node1" [
label = "<f0> 0xf7fc4380| <f1> | <f2> |-1"
shape = "record"
];
"node2" [
label = "<f0> 0xf7fc44b8| | |2"
shape = "record"
];
"node3" [
label = "<f0> 3.43322790286038071e-06|44.79998779296875|0"
shape = "record"
];
"node4" [
label = "<f0> 0xf7fc4380| <f1> | <f2> |2"
shape = "record"
];
"node5" [
label = "<f0> (nil)| | |-1"
shape = "record"
];
"node6" [
label = "<f0> 0xf7fc4380| <f1> | <f2> |1"
shape = "record"
];
"node7" [
label = "<f0> 0xf7fc4380| <f1> | <f2> |2"
shape = "record"
];
"node8" [
label = "<f0> (nil)| | |-1"
shape = "record"
];
"node9" [
label = "<f0> (nil)| | |-1"
shape = "record"
];
"node10" [
label = "<f0> (nil)| <f1> | <f2> |-1"
shape = "record"
];
"node11" [
label = "<f0> (nil)| <f1> | <f2> |-1"
shape = "record"
];
"node12" [
label = "<f0> 0xf7fc43e0| | |1"
shape = "record"
];
"node0":f0 -> "node1":f0 [
id = 0
];
"node0":f1 -> "node2":f0 [
id = 1
];
"node1":f0 -> "node3":f0 [
id = 2
];
"node1":f1 -> "node4":f0 [
id = 3
];
"node1":f2 -> "node5":f0 [
id = 4
];
"node4":f0 -> "node3":f0 [
id = 5
];
"node4":f1 -> "node6":f0 [
id = 6
];
"node4":f2 -> "node10":f0 [
id = 7
];
"node6":f0 -> "node3":f0 [
id = 8
];
"node6":f1 -> "node7":f0 [
id = 9
];
"node6":f2 -> "node9":f0 [
id = 10
];
"node7":f0 -> "node3":f0 [
id = 11
];
"node7":f1 -> "node1":f0 [
id = 12
];
"node7":f2 -> "node8":f0 [
id = 13
];
"node10":f1 -> "node11":f0 [
id = 14
];
"node10":f2 -> "node12":f0 [
id = 15
];
"node11":f2 -> "node1":f0 [
id = 16
];
}
</graphviz>


External links