Tree Layout does not properly layout all the links as expected

Article ID: 2279
Last updated: 29 May, 2018
Article ID: 2279
Last updated: 29 May, 2018
Revision: 3
Views: 492
Posted: 06 Nov, 2007
by Dean J.
Updated: 29 May, 2018
by Gargani A.

Question

Why the Tree Layout does not properly layout all the links?

Answer

In some cases, the Tree Layout does not remove all the bend points or some links do not follow the general orientation. It occurs in any mode (free,tip-over, level, radial, alternating radial, and so on.)

This happens when the graph is non-tree. The Tree Layout algorithm respects only a spanning tree of the graph and ignores all other non-tree links. For more information on the spanning tree and non-tree links, refer to the documentation under the Using Graph Layout Algorithms > Layout Algorithms > Tree Layout > What Types of Graphs section.
To make sure that all links are taken into account when the layout is performed, use one of the following alternatives:

  • Since JViews 6.0, use the option treeLayout.setNonTreeLinksStraight(true). This ensures that all links are made straight, unless they belong to the tree structure of the graph, in which case the link style of the tree layout is applied.
  • Before JViews 6.0, use the Hierarchical layout. If you try to use the free or level mode of Tree layout, consider using the Hierarchical layout instead, which is designed for non-tree graphs and will take into account all links in the graph.
  • Apply two layouts to the graph: first the Tree layout, then the Link layout (to take care of the non-tree links). Since the Link Layout only needs to perform on the non-tree links, you need to traverse through the graph and call IlvLinkLayout.setFixed on each of the "tree" links, then call setPreserveFixedLinks on the Link Layout to prevent reshaping the links indicated as fixed.

    You can identify the non-tree links by:

    1. Letting the Tree layout categorize the links by calling, BEFORE the layout:

      treeLayout.setCategorizingLinks(true);

    2. So that, AFTER tree layout, you can query the tree links:

      //Returns the links of the spanning tree
      //that are oriented in tree flow direction.
      Enumeration getCalcForwardTreeLinks()

      //Returns the links of the spanning tree that are
      //oriented against tree flow direction.
      Enumeration getCalcBackwardTreeLinks()

      //Returns the links that are not part of the
      // spanning tree at all.

      Enumeration getCalcNonTreeLinks()

    3. This means that you iterate over getCalcForwardTreeLinks() and over getCalcBackwardTreeLinks(), and set these links as fixed for the link layout.
This article was:   Helpful | Not helpful
Report an issue
Article ID: 2279
Last updated: 29 May, 2018
Revision: 3
Views: 492
Posted: 06 Nov, 2007 by Dean J.
Updated: 29 May, 2018 by Gargani A.
Also listed in


Others in this category