Class JGraphHierarchyModel
java.lang.Object
com.jgraph.layout.hierarchical.model.JGraphHierarchyModel
Internal model of a hierarchical graph. This model stores nodes and edges
equivalent to the real graph nodes and edges, but also stores the rank of the
cells, the order within the ranks and the new candidate locations of cells.
The internal model also reverses edge direction were appropriate , ignores
self-loop and groups parallels together under one edge object.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether or not cells are ordered according to the order in the graph model.protected intCount of the number of times the ancestor dfs has been usedprotected MapMap from graph edges to internal model edgesintStores the largest rank number allocatedMapping from rank number to actual rankObject[]Store of roots of this hierarchy model, these are real graph cells, not internal cellsprotected booleanWhether the rank assignment is done from the sinks or sources.protected MapMap from graph vertices to internal model nodes -
Constructor Summary
ConstructorsConstructorDescriptionJGraphHierarchyModel(JGraphFacade facade) Constructor with no parameters creates a default modelJGraphHierarchyModel(JGraphFacade facade, Object[] vertices, boolean ordered, boolean deterministic, boolean scanRanksFromSinks) Creates an internal ordered graph model using the vertices passed in. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcreateInternalCells(JGraphFacade facade, Object[] vertices, JGraphHierarchyNode[] internalVertices) Creates all edges in the internal modelvoiddfs(JGraphHierarchyNode parent, JGraphHierarchyNode root, JGraphHierarchyEdge connectingEdge, JGraphFacade.CellVisitor visitor, Set seen, int layer) Performs a depth first search on the internal hierarchy modelvoiddfs(JGraphHierarchyNode parent, JGraphHierarchyNode root, JGraphHierarchyEdge connectingEdge, JGraphFacade.CellVisitor visitor, Set seen, int[] ancestors, int childHash, int layer) Performs a depth first search on the internal hierarchy model.voiddfs(JGraphFacade.CellVisitor visitor, Object[] dfsRoots, boolean trackAncestors, Set seenNodes) A depth first search through the internal heirarchy modelvoidfixRanks()Fixes the layer assignments to the values stored in the nodes.voidformOrderedHierarchy(JGraphFacade facade, Object[] vertices) Creates an internal ordered graph model using the vertices passed in.intvoidBasic determination of minimum layer ranking by working from from sources or sinks and working through each node in the relevant edge direction.booleanbooleanvoidsetDeterministic(boolean deterministic) voidsetDfsCount(int dfsCount) voidsetEdgeMapper(Map edgeMapper) voidsetSinksAtLayerZero(boolean sinksAtLayerZero) voidsetVertexMapping(Map vertexMapping)
-
Field Details
-
scanRanksFromSinks
protected boolean scanRanksFromSinksWhether the rank assignment is done from the sinks or sources. -
maxRank
public int maxRankStores the largest rank number allocated -
vertexMapper
Map from graph vertices to internal model nodes -
edgeMapper
Map from graph edges to internal model edges -
ranks
Mapping from rank number to actual rank -
roots
Store of roots of this hierarchy model, these are real graph cells, not internal cells -
dfsCount
protected int dfsCountCount of the number of times the ancestor dfs has been used -
deterministic
protected boolean deterministicWhether or not cells are ordered according to the order in the graph model. Defaults to false since sorting usually produces quadratic performance. Note that since JGraph 6 returns edges in a deterministic order, it might be that this layout is always deterministic using that JGraph regardless of this flag setting (i.e. leave it false in that case)
-
-
Constructor Details
-
JGraphHierarchyModel
Constructor with no parameters creates a default model- Parameters:
facade- the facade of the graph to be laid out
-
JGraphHierarchyModel
public JGraphHierarchyModel(JGraphFacade facade, Object[] vertices, boolean ordered, boolean deterministic, boolean scanRanksFromSinks) Creates an internal ordered graph model using the vertices passed in. If there are any, leftward edge need to be inverted in the internal model- Parameters:
facade- the facade describing the graph to be operated onvertices- the vertices for this hierarchyordered- whether or not the vertices are already ordereddeterministic- whether or not this layout should be deterministic on each usagescanRanksFromSinks- Whether the rank assignment is done from the sinks or sources.
-
-
Method Details
-
formOrderedHierarchy
Creates an internal ordered graph model using the vertices passed in. If there are any, leftward edge need to be inverted in the internal model- Parameters:
facade- the facade describing the graph to be operated onvertices- the vertices to be laid out
-
createInternalCells
protected void createInternalCells(JGraphFacade facade, Object[] vertices, JGraphHierarchyNode[] internalVertices) Creates all edges in the internal model- Parameters:
facade- the facade desrcibing the graph to be laid outvertices- the vertices whom are to have an internal representation createdinternalVertices- the blank internal vertices to have their information filled in using the real vertices
-
initialRank
public void initialRank()Basic determination of minimum layer ranking by working from from sources or sinks and working through each node in the relevant edge direction. Starting at the sinks is basically a longest path layering algorithm. -
fixRanks
public void fixRanks()Fixes the layer assignments to the values stored in the nodes. Also needs to create dummy nodes for edges that cross layers. -
dfs
public void dfs(JGraphFacade.CellVisitor visitor, Object[] dfsRoots, boolean trackAncestors, Set seenNodes) A depth first search through the internal heirarchy model- Parameters:
visitor- the visitor pattern to be called for each nodetrackAncestors- whether or not the search is to keep track all nodes directly above this one in the search path
-
dfs
public void dfs(JGraphHierarchyNode parent, JGraphHierarchyNode root, JGraphHierarchyEdge connectingEdge, JGraphFacade.CellVisitor visitor, Set seen, int layer) Performs a depth first search on the internal hierarchy model- Parameters:
parent- the parent internal node of the current internal noderoot- the current internal nodeconnectingEdge- the internal edge connecting the internal node and the parent internal node, if anyvisitor- the visitor pattern to be called for each nodeseen- a set of all nodes seen by this dfs a set of all of the ancestor node of the current nodelayer- the layer on the dfs tree ( not the same as the model ranks )
-
dfs
public void dfs(JGraphHierarchyNode parent, JGraphHierarchyNode root, JGraphHierarchyEdge connectingEdge, JGraphFacade.CellVisitor visitor, Set seen, int[] ancestors, int childHash, int layer) Performs a depth first search on the internal hierarchy model. This dfs extends the default version by keeping track of cells ancestors, but it should be only used when necessary because of it can be computationally intensive for deep searches.- Parameters:
parent- the parent internal node of the current internal noderoot- the current internal nodeconnectingEdge- the internal edge connecting the internal node and the parent internal node, if anyvisitor- the visitor pattern to be called for each nodeseen- a set of all nodes seen by this dfsancestors- the parent hash codechildHash- the new hash code for this nodelayer- the layer on the dfs tree ( not the same as the model ranks )
-
getVertexMapping
- Returns:
- Returns the vertexMapping.
-
setVertexMapping
- Parameters:
vertexMapping- The vertexMapping to set.
-
getEdgeMapper
- Returns:
- Returns the edgeMapper.
-
setEdgeMapper
- Parameters:
edgeMapper- The edgeMapper to set.
-
getDfsCount
public int getDfsCount()- Returns:
- Returns the dfsCount.
-
setDfsCount
public void setDfsCount(int dfsCount) - Parameters:
dfsCount- The dfsCount to set.
-
isDeterministic
public boolean isDeterministic()- Returns:
- Returns the deterministic.
-
setDeterministic
public void setDeterministic(boolean deterministic) - Parameters:
deterministic- The deterministic to set.
-
isSinksAtLayerZero
public boolean isSinksAtLayerZero() -
setSinksAtLayerZero
public void setSinksAtLayerZero(boolean sinksAtLayerZero)
-