skip to main content
Diagrammer > Programmer's documentation > Using graph layout algorithms > Using advanced features > FAQs about using the layout algorithms
 
FAQs about using the layout algorithms
The following list of FAQs provides some helpful suggestions for using the layout algorithms. You might find some answers to questions that come up when using the graph layout package.
FAQs about the layout algorithms  
Question
Answer
I perform the layout and nothing happens (no node is moved). Why?
One possible reason can be: the layout algorithms provided in Rogue Wave®  JViews Diagrammer are all designed to do nothing, by default, if no change occurred in the graph since the last time the layout was performed successfully on the same graph. A change means that a node was moved, or a node or link was added, removed, or reshaped.
Note that you can force the layout to be performed again, even if no change occurred, by calling the performLayout method with a true value for the force argument. (In the Composer demonstration, you can choose this option in the Options menu.)
Another possible reason can be: an error or a special case occurred during the layout. First, you must check whether the performLayout method has thrown an exception. If no exception was thrown, call the getCode method on the instance of the layout report returned by the performLayout method. Check this value with respect to the documentation of the appropriate layout report class. (For details, see Using a graph layout report.)
With the Uniform Length Edges algorithm in incremental mode, after having performed the layout once, I do not see any movement even if I use the force layout option. Why?
The reason is probably that the first time you performed the layout, the algorithm reached the convergence. When the layout is performed again, it detects that the convergence has been already reached and stops. If you really want to continue working, for instance in order to “declutter” a particular part of the graph, you may need to move one or several nodes in order to change the initial configuration. (The algorithm is dependent on the initial configuration.)
After performing the layout, the graph is laid out far from its initial position. Why?
Most of the layout algorithms use a layout region parameter to control the size and position of the layout. (For details, see Layout region.) Depending on the value of this parameter, the nodes may be moved far from their initial positions.
To know whether a layout algorithm is designed to use a layout region parameter, check the documentation to see if the layout class overrides the supportsLayoutRegion method of the base class in order to return true.
Other algorithms have a different mechanism that allows you to specify the location of the layout. It may happen that the default value of the location parameter is such that the graph is laid out far from its initial position.
When I use certain layout algorithms on certain graphs, there are overlapping nodes. Why and what can I do?
One possible reason can be related to the different ways layout algorithms deal with the size of the nodes:
-The Topological Mesh algorithm is not able to explicitly take into account the size of the nodes.
- The Tree, Hierarchical, Bus, and Grid algorithms always avoid overlapping nodes. (The Link algorithm does not move the nodes. It only reshapes the links such that the crossings and overlaps are reduced. The size of the nodes is taken into account.)
- The Uniform Length Edges algorithm (with the option “Respect Node Sizes” enabled) and the Circular algorithm, in many cases, succeed in avoiding overlapping nodes.
In any case, if the layout algorithm supports the layout region mechanism (see Layout region), you should try to increase the size of the layout region. For example, if your graph contains hundreds of nodes, it is not reasonable to use a small layout region, such as 600x600. There will be not enough space for all the nodes. You should try a larger layout region, for example 5000x5000.
The optimal size of the layout region depends not only on the number of nodes, but also on their size. If the nodes are relatively large with respect to the size of the layout region, it might be necessary to adjust some of the parameters (for instance, the preferred link length for the Uniform Length Edges Layout).
In some networks, there are two (or more) subnetworks that are not connected. How does this affect the layout algorithms?
It depends on the layout class you use:
- IlvTopologicalMeshLayout: It will work on the connected component of the graph that contains the starting node. (You can specify this node as a parameter.) If the “starting node” is not specified, it is automatically chosen in an arbitrary way. The nodes of the other “connected components” will not be moved. You may want to perform the layout separately on each connected component using different layout regions and starting node settings. This is what you get automatically when you enable the “layout of connected components” parameter. (See Layout of connected components.)
- IlvUniformLengthEdges: This algorithm supports disconnected graphs, but usually it is better to rely on the automatic “layout of connected components” parameter. (See Layout of connected components.)
- IlvBusLayout: It will work on the “connected component” of the graph that contains the “bus object.” (You must specify the bus object as a parameter.) The other nodes that are not connected to the bus will not be moved. You may need to perform the layout separately on each connected component. This is what you get automatically when you enable the “layout of connected components” parameter. (See Layout of connected components.)
- IlvCircularLayout, IlvHierarchicalLayout, IlvTreeLayout: They have built-in support for disconnected graphs. Alternatively, you can use the automatic support from the base class. (See Layout of connected components.)
- IlvLinkLayout, IlvGridLayout, IlvRandomLayout: These algorithms support both connected and disconnected graphs. Their behavior is the same for both categories of graphs.
There are some attributes of the network that we know about (for instance, we know what the core switch is and what the center must be). Are such attributes taken into account by the layout algorithm?
It depends on the layout algorithm.
- The Circular Layout is designed to allow you to specify information about the physical topology of the network. You can specify which nodes belong to the same cluster (ring or star), the order of the nodes on the cluster, and which node is the center of a star cluster.
- In the Tree Layout, you can specify the root node.
- In the Bus Layout algorithm, you can specify the bus object.
- In the Hierarchical Layout algorithm, you can specify node position indices and level indices, as well as relative positioning constraints.
If I use Rogue Wave  JViews Diagrammer on different computers or with different Java™ Virtual Machines (JVM™) or both, I sometimes get different layouts for the same graph and with the same parameters. Why?
There are two possible reasons:
1. Different computers and JVMs can be slower or faster. If the layout algorithm you use stops the computation when the specified allowed time has elapsed, a slower computer or JVM causes the computation to stop earlier. It can explain different results. This may happen even with the same computer and JVM if the charge of the computer is increased. You may need to increase the allowed time specification when running on a slower computer or JVM.
2. If you use a layout algorithm that uses the random generator and if you use the default option for the seed value (that is, the system clock is used), you get different results for each successive run of the layout on the same graph. This allows you to obtain alternative results and to chose the one you prefer. If you want to prevent different results for successive runs, you can specify a constant seed value.
I use the Link Layout algorithm to lay out the links (representing routes) of a network of graphical objects (towns) geo-positioned on a cartographical map. When several links connect to the same side of a node, they overlap, while I expect them to respect the “link offset” (or the “grid size”) parameter of the Link Layout.
Why?
Some dimensional parameters of the layout algorithms need to be chosen with respect to the size of the nodes. It is the case of the “link offset” and the “bypass distance” parameters for the Short Link Layout, and the grid size for the Long Link Layout. Indeed, their default values are not appropriate when the nodes are large. Often, nodes placed on a map, for instance a world map, have a very large size. Compared to this size, the default values of the parameters are so small that they appear to be zero.
The solution is to increase the values of the dimensional parameters, taking into account the size of the nodes. If different nodes have different sizes, either the medium or the largest size of the nodes can be used to compute the parameters as a fraction of this size.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.