Class MultilevelGraph

java.lang.Object
org.vanted.plugins.layout.multilevelframework.MultilevelGraph

public class MultilevelGraph
extends Object
This class stores the coarsening levels of a graph, as well as the original graph.
  • Constructor Details

    • MultilevelGraph

      public MultilevelGraph​(Graph level_0)
      Create a MultilevelGraph. Initially only the original graph will be contained. New coarsening levels can be added, e.g. by calling {@link this#newCoarseningLevel()}.
      Parameters:
      level_0 - The original graph. Must not be null.
  • Method Details

    • getNumberOfLevels

      public int getNumberOfLevels()
      Calculate the number of levels.
      Returns:
      the number of levels (including the original graph)
    • getTotalNumberOfNodes

      public int getTotalNumberOfNodes()
      Returns:
      the total number of nodes contained within all the levels (including the original graph).
    • getTopLevel

      public Graph getTopLevel()
      Get the topmost (i.e. the "coarsest") coarsening level.
      Returns:
      the topmost coarsening level or the original graph if there are no coarsened versions.
    • newCoarseningLevel

      public int newCoarseningLevel()
      Create a new coarsening level, based on the current top one (i.e. the one returned by getTopLevel()). Note that this method will throw an IllegalStateException if the current coarsening level is not complete (see isComplete()).
      Returns:
      the level number of the new coarsening level (starting at 1, the original graph is level 0)
    • popCoarseningLevel

      public CoarsenedGraph popCoarseningLevel()
      Removes the coarsest coarsening level. This is supposed to used by implementations of the Placer interface. This method can only be called if getNumberOfLevels() >= 2 (i.e. the original graph cannot be removed).
      Returns:
      the topmost coarsening level
    • addNode

      public MergedNode addNode​(Set<Node> representedNodes)
      Add a new MergedNode to the topmost coarsening level (i.e. the one returned by getTopLevel())
      Parameters:
      representedNodes - The Nodes that the MergedNode represents. Note that you add new represented Nodes later using the methods of MergedNode.
      Returns:
      the MergedNode that was created.
    • isComplete

      public boolean isComplete()
      Checks whether the top level is complete, i.e. whether all nodes in the underlying level are represented by a MergedNode in the top level. Note that this is a rather expensive computation. Also note that this obviously requires that at least one coarsening level exist.
      Returns:
      true if the level is complete or false otherwise
    • addEdge

      public Edge addEdge​(Node source, Node target)
      Adds an undirected AdjListEdge to the topmost level (i.e. the one returned by getTopLevel()) connecting two MergedNodes.
      Parameters:
      source - The edge's source. Must not be null.
      target - The edge's target. Must not be null.
      Returns:
      The newly created edge.