OrganicEdgeRouter
routes edges
organically to ensure that they do not overlap nodes and that they keep a
specifiable minimal distance to the nodes.
It is especially well suited for non-orthogonal, organic or cyclic layout
styles.
The algorithm is based on a force directed layout paradigm. Nodes act as repulsive forces on edges in order to guarantee a certain minimal distance between nodes and edges. Edges tend to contract themselves. Using simulated annealing, this finally leads to edge layouts that are calculated for each edge separately.
This algorithm will only work correctly if there is enough room between each pair of nodes in the graph. In particular, there should be a distance of at least twice the minimal distance (see below) between any two nodes.
In order to ensure that these preconditions are met, the technique described below can be used.
Figure 5.69. Sample edge routings produced with OrganicEdgeRouter
![]() |
![]() |
| Postprocessing edge routing of an organically laid out tree. | Automatic edge routing of a hand-laid-out graph structure. |
If this option is activated only selected edges will be considered for rerouting.
This specifies the minimal allowed distance between nodes and edges.
This option specifies whether existing bends should be used as an initial solution for the new routing.
If this option is activated only edges that violate the minimal distance criterion will be rerouted.
This option specifies whether edges are allowed to overlap with nodes. Enabling this option often improves the routing when nodes are not allowed to move (i.e., when using the node enlargement layout stage is not an option), and some distances between nodes do not comply with the algorithm's preconditions. Note that the minimal distance cannot always be maintained when using this option.
In order to ensure that the preconditions of OrganicEdgeRouter are met for
arbitrary graphs, the routing process can be enhanced using specialized layout
stages.
In particular, the
createNodeEnlargementStage()
method returns a layout stage that perfectly lends itself for usage in
conjunction with logic that creates more space between the nodes of a graph.
The code in Example 5.37, “Ensuring OrganicEdgeRouter's preconditions” presents this
technique.
Example 5.37. Ensuring OrganicEdgeRouter's preconditions
// 'graph' is of type y.layout.LayoutGraph. OrganicEdgeRouter oer = new OrganicEdgeRouter(); LayoutStage nodeEnlarger = oer.createNodeEnlargementStage(); CompositeLayoutStage cls = new CompositeLayoutStage(); cls.appendStage(nodeEnlarger); cls.appendStage(new BendConverter()); cls.appendStage(new RemoveOverlapsLayoutStage(0.0)); oer.setCoreLayouter(cls); oer.doLayout(graph);
The following yFiles source code demo programs demonstrate how OrganicEdgeRouter can be used within an application.
|
Copyright ©2004-2010, yWorks GmbH. All rights reserved. |