Organic Layout

Class OrganicLayouter is a multi-purpose layouter for undirected graphs. It produces clear representations of complex networks and is especially fit for application areas such as

OrganicLayouter is based on the force-directed layout paradigm. When calculating a layout, the nodes are considered to be physical objects with mutually repulsive forces, like, e.g., protons or electrons. The connections between nodes also follow the physical analogy and are considered to be metal springs attached to the pair of nodes. These springs produce repulsive or attractive forces between their end points if they are too short or too long. The layouter simulates these physical forces and rearranges the positions of the nodes in such a way that the sum of the forces emitted by the nodes and the edges reaches a (local) minimum.

Resulting layouts often expose the inherent symmetric and clustered structure of a graph, a well-balanced distribution of nodes and few edge crossings.

The layouter is well suited for the visualization of highly connected backbone regions with attached peripheral ring or star structures. These structurally different regions of a network can be easily identified by looking at a drawing produced by this layouter.

See the Smart Organic Layouter for another layouter which makes use of this layouter and related layouting techniques.

Figure 5.38. Sample layouts produced by class OrganicLayouter

Sample layouts produced by class OrganicLayouter
Sample layouts produced by class OrganicLayouter
Sample layouts produced by class OrganicLayouter
The network represents mount point relationships in a shared file system. The inherent symmetry of this recursively defined graph gets exposed nicely. The inherent symmetry of this extended short-cut grid-graph gets exposed nicely.

Supplemental Layout Data

Class OrganicLayouter knows a number of data provider keys which are used to retrieve supplemental layout data for a graph's elements. The data is bound to the graph by means of a data provider, which is registered using a given look-up key. Table 5.20, “Data provider look-up keys” lists all look-up keys for OrganicLayouter.

Binding supplemental layout data to a graph is described in the section called “Providing Supplemental Layout Data”.

Table 5.20. Data provider look-up keys

Key Element Type Value Type Description
GROUP_DPKEY Node boolean For each node a boolean value indicating whether it is a group node or not.
NODE_ID_DPKEY Node Object For each node an Object that serves as a unique ID.
PARENT_NODE_ID_DPKEY Node Object For each node an Object indicating the group node it belongs to. The Object matches the unique ID of a group node that is in the same graph.
SPHERE_OF_ACTION_NODES Node boolean For each node a boolean value indicating whether it should be treated as selected or not.
PREFERRED_EDGE_LENGTH_DATA Edge int For each edge an integral value that indicates its preferred length.
FIXED_GROUP_NODES_DPKEY Node boolean For each group node a boolean value indicating whether its content should remain fixed or not.

Setup of a graph's hierarchical organization and using the grouping keys (GROUP_DPKEY, NODE_ID_DPKEY, and PARENT_NODE_ID_DPKEY) is described in detail in the section called “Setup for Layout”.

Layout Options

Organic layout provides a set of options that influence its behavior. These options can be set using the setter methods of class OrganicLayouter.

Sphere of Action (see API)

Determines the set of nodes from the graph that should be processed.

When only a subset should be rearranged, a data provider holding the selection state for each node is looked up. The data provider is expected to be registered with the graph using key SPHERE_OF_ACTION_NODES.

All
The whole graph will be considered for layout.
Mainly Selection
The selected nodes will be rearranged. The unselected nodes are only allowed to move to a certain degree.
Only Selection
Only the selected nodes will be rearranged.

Figure 5.39, “Initial graph and an augmentation” and Figure 5.40, “Incremental layout of augmented graph” show how the "Sphere of Action" option enables different kinds of incremental layout strategies. To perform incremental layout, some nodes have to be marked as "selected." Only (or mostly) the selected nodes will be arranged by OrganicLayouter. All other nodes will stay at their original position.

Figure 5.39. Initial graph and an augmentation

Initial graph and an augmentation
Initial graph and an augmentation

Figure 5.40. Incremental layout of augmented graph

Incremental layout of augmented graph
Incremental layout of augmented graph
Incremental layout of augmented graph
Setting "Sphere of Action" to ALL results in a complete re-layout of the augmented graph. No incremental feature here. Setting "Sphere of Action" to ONLY_SELECTION. This places only selected (here: red) nodes and leaves other nodes untouched. Simple incremental feature. Setting "Sphere of Action" to MAINLY_SELECTION. This places selected (here: red) nodes and moves other nodes only a little bit. Smart incremental feature.

Initial Placement (see API)

Determines the initial placement of the nodes from where the layuter starts to find a good resulting layout.

Random
The nodes are randomly placed. This is a good choice, if nothing is known about the input graph or if completely different layout results are desired for successive calls to the layouter.
At (0, 0)
All nodes will be placed at the same location (0, 0).
As Is
The layouter starts with the given coordinates. This is a good choice, if the given layout is similar to the desired layout.

Preferred Edge Length (see API)

Allows to specify the general preferred length for all edges. The layouter tries to arrange the nodes in such a way that the edges have the desired edge length. If "Obey Node Size" is checked, then the edge length is measured from node border to node border. Otherwise, the edge length is measured from node center to node center.

To specify the preferred edge length for each edge individually, a data provider holding such supplemental layout data can be bound to the graph. The data provider is expected to be registered with the graph using key PREFERRED_EDGE_LENGTH_DATA. Note that in the absence of an individual preferred edge length the general preferred edge length will be used.

Gravity Factor (see API)

Regulates the tendency of the nodes to be placed near the barycenter of the resulting layout. The greater the factor, the closer are the nodes to the barycenter. Negative values lead to huge layouts.

Figure 5.41, “Effect of the gravity factor” shows the effect of different gravity settings. The magnitude of the gravity factor determines the strength of the force towards the barycenter of the graph. A high gravity factor tends to cluster nodes around the barycenter of the graph. A low factor stretches the outskirts of the graph far away from the center. By default a value of 0.0 is assumed.

Figure 5.41. Effect of the gravity factor

Effect of the gravity factor
Effect of the gravity factor
Effect of the gravity factor
Effect of the gravity factor
Gravity = -0.2 Gravity = 0.0 Gravity = 0.5 Gravity = 2.0

Obey Node Size (see API)

Whether or not to obey the size of the nodes when calculating the layout. The distance between two nodes is calculated with respect to the node sizes, i.e., for equal preferred edge lengths, activating this feature will lead to bigger layouts.

Attraction (see API)

This setting determines the strength of the force that edges oppose on their adjacent nodes. Higher values result in edges which better obey the given preferred edge length.

Repulsion (see API)

This setting determines the strength of the forces that nodes oppose on their topological neighbors. Higher values result in greater node distances. In this case, preferred edge lengths are more likely to be longer than the preferred edge length.

Figure 5.42, “A graph laid out using different repulsion factors” shows how the "Repulsion" option affects the layout. The value determines repulsion through the inverse power of the distance between two nodes, i.e., smaller values lead to slowly degrading repulsion, whereas greater values simulate local repulsion only. Notice the increasing localness of mutual node repulsion for increasing factors.

Figure 5.42. A graph laid out using different repulsion factors

A graph laid out using different repulsion factors
A graph laid out using different repulsion factors
A graph laid out using different repulsion factors
Repulsion = 0 Repulsion = 1 Repulsion = 2

Activate Tree Beautifier (see API)

Activates an experimental feature that lays out tree-like sub-structures of the graph in an optimized way.

Iteration Factor (see API)

Influences the quality and execution time of this layouter. Greater values may result in better quality and most likely longer execution time.

Maximum Duration (see API)

Sets the maximal duration of the layout process in milliseconds. If this upper bound is hit during the layout process, the quality of the may not be optimal. Increasing this values increases the likeliness of an optimal layout.

Activate Deterministic Mode (see API)

Whether or not the layout process should be deterministic. In deterministic mode the layouter produces identical results for identical input graphs.

Advanced Layout Features

The organic layout algorithm implemented in yFiles allows to layout hierarchically organized graphs. Both position and dimension of group nodes will be calculated by the algorithm. Additional size requirements (insets or custom labels) can be provided for each group node separately (see API and API).

Figure 5.43. Organic layout of a hierarchically organized graph

Organic layout of a hierarchically organized graph

Group Node Policy (see API)

Determines the basic policy for the layout process.

To keep the contents of only certain group nodes fixed, a data provider holding such supplemental layout data can be bound to the graph. The data provider is expected to be registered with the graph using key FIXED_GROUP_NODES_DPKEY.

Layout Groups
Instructs the algorithm to layout group nodes as well as their contents in a global manner. The positions of all visible nodes will be recalculated.
Fix Contents of Groups
The algorithm will keep the relative position of nodes inside of group nodes and performs the layout on the top level only, taking the position of nodes inside the group nodes into account.
Ignore Groups
This setting will make the algorithm ignore group nodes entirely. Nodes will be rearranged as if there were no group nodes. This may lead to overlapping group nodes.

Group Node Compactness (see API)

This setting can be used to control the compactness of group nodes. Larger values will lead to more compact group nodes but inter-edges may be longer and nodes inside group nodes tend to get clutched together at the center of the group node. Smaller values will result in larger group nodes in favor of shorter inter-edge lengths and more evenly spread nodes inside group nodes.

Incremental Layout

OrganicLayouter supports incremental layout through the "Sphere of Action" feature. See the above description.

Tutorial Demo Code

Layout module OrganicLayoutModule.java presents the setup of class OrganicLayouter in an application context.