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 Summary
Constructors Constructor Description MultilevelGraph(Graph level_0)
Create aMultilevelGraph
. -
Method Summary
Modifier and Type Method Description Edge
addEdge(Node source, Node target)
Adds an undirectedAdjListEdge
to the topmost level (i.e.MergedNode
addNode(Set<Node> representedNodes)
Add a newMergedNode
to the topmost coarsening level (i.e.int
getNumberOfLevels()
Calculate the number of levels.Graph
getTopLevel()
Get the topmost (i.e.int
getTotalNumberOfNodes()
boolean
isComplete()
Checks whether the top level is complete, i.e.int
newCoarseningLevel()
Create a new coarsening level, based on the current top one (i.e.CoarsenedGraph
popCoarseningLevel()
Removes the coarsest coarsening level.
-
Constructor Details
-
MultilevelGraph
Create aMultilevelGraph
. 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 benull
.
-
-
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
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 bygetTopLevel()
). Note that this method will throw anIllegalStateException
if the current coarsening level is not complete (seeisComplete()
).- Returns:
- the level number of the new coarsening level (starting at
1
, the original graph is level0
)
-
popCoarseningLevel
Removes the coarsest coarsening level. This is supposed to used by implementations of thePlacer
interface. This method can only be called ifgetNumberOfLevels()
>= 2 (i.e. the original graph cannot be removed).- Returns:
- the topmost coarsening level
-
addNode
Add a newMergedNode
to the topmost coarsening level (i.e. the one returned bygetTopLevel()
)- Parameters:
representedNodes
- TheNode
s that theMergedNode
represents. Note that you add new representedNode
s later using the methods ofMergedNode
.- 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 aMergedNode
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 orfalse
otherwise
-
addEdge
Adds an undirectedAdjListEdge
to the topmost level (i.e. the one returned bygetTopLevel()
) connecting twoMergedNode
s.- Parameters:
source
- The edge's source. Must not benull
.target
- The edge's target. Must not benull
.- Returns:
- The newly created edge.
-