Wgraph:Tutorial graph layout

From FollowTheScore
Jump to: navigation, search

Layout Algorithms

The parameter 'layout' (or 'layoutalgorithm') is used to select an algorithm:

  • forcedir
  • normal
  • maxdepth
  • mindepth
  • dfs
  • maxdepthslow
  • mindepthslow
  • maxindegree
  • minindegree
  • maxoutdegree
  • minoutdegree
  • maxdegree
  • mindegree
  • minbackward
  • tree

Beyond that you can use 'layer' to assign a node to a layer (symbolic name). If you use layer names, edges will be flipped to make sure that they always point from the node with the lower layer to the one with a higher layer. When an edge is flipped the arrowhead is also flipped, so that you don not see a difference - apart from the changed layout. Layers do not work with forcedir layout.

The following example will normally produce the graph shown:

{{#wgraph:name={{PAGENAME}}_1|svg|thumb=30|
  node a {}
  node b {}
  node c {}
  edge a b {}
  edge c b {}
}}

{{#wgraph:name=Tutorial graph layout_1|svg|thumb=30|

 node a {}
 node b {}
 node c {}
 edge a b {}
 edge c b {}

}}

Using 'layers' you can enforce that c is placed in the third layer/level {{#wgraph:name=Tutorial graph layout_2|svg|thumb=30|

 node a {layer alpha}
 node b {layer xyz  }
 node c {layer zulu }
 edge a b {}
 edge c b {}

}}

The same could be achieved using the 'level' command: {{#wgraph:name=Tutorial graph layout_3|svg|thumb=30|

 node a { level 0 }
 node b { level 1 }
 node c { level 2 }
 edge a b {}
 edge c b {}

}}