java.lang.Object
org.jhotdraw8.graph.AbstractMutableIndexedBidiGraph
- All Implemented Interfaces:
IndexedBidiGraph,IndexedDirectedGraph
AbstractDirectedGraphBuilder.
Implementation:
Example graph:
0 ──→ 1 ──→ 2
│ │
↓ ↓
3 ←── 4
If the graph is inserted in the following sequence
into the builder:
buildAddVertex();
buildAddVertex();
buildAddVertex();
buildAddVertex();
buildAddVertex();
buildAddVertex();
build.addArrow(0, 1);
build.addArrow(0, 3);
build.addArrow(1, 2);
build.addArrow(1, 4);
build.addArrow(4, 3);
Then the internal representation is as follows:
vertexCount: 5
vertex# nodes
0 Node.next{1,3}
1 Node.next{2,4}.prev{0}
2 Node.prev{1}
3 Node.prev{0}.prev{4}
4 Node.next{3}.prev{1}
- Author:
- Werner Randelshofer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbuildAddArrow(int vidx, int uidx) Builder-method: adds a directed arrow from 'v' to 'u'.protected voidprotected voidbuildAddVertices(int count) protected voidbuildRemoveArrow(int vidx, int uidx) Removes an arrow from v to u.protected voidbuildRemoveArrowAt(int vidx, int i) Removes the i-th arrow of vertex v.protected voidbuildRemoveVertex(int vidx) intReturns the number of arrows.intgetNextAsInt(int v, int index) Returns thei-th next vertex ofv.intgetNextCount(int v) Returns the number of next vertices of v.intgetPrevAsInt(int v, int i) Returns thei-th previous vertex ofv.intgetPrevCount(int v) Returns the number of direct predecessor vertices of v.intReturns the number of verticesV.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jhotdraw8.graph.IndexedBidiGraph
findIndexOfPrevAsInt, getPrevArrowAsInt, isPrevAsInt, prevVerticesEnumeratorMethods inherited from interface org.jhotdraw8.graph.IndexedDirectedGraph
findIndexOfNextAsInt, getNextArrowAsInt, isNextAsInt, nextVerticesEnumerator
-
Constructor Details
-
AbstractMutableIndexedBidiGraph
public AbstractMutableIndexedBidiGraph() -
AbstractMutableIndexedBidiGraph
public AbstractMutableIndexedBidiGraph(int vertexCount) -
AbstractMutableIndexedBidiGraph
-
-
Method Details
-
buildAddVertex
protected void buildAddVertex() -
buildAddVertices
protected void buildAddVertices(int count) -
buildRemoveVertex
protected void buildRemoveVertex(int vidx) -
buildAddArrow
protected void buildAddArrow(int vidx, int uidx) Builder-method: adds a directed arrow from 'v' to 'u'.- Parameters:
vidx- index of vuidx- index of u
-
buildRemoveArrow
protected void buildRemoveArrow(int vidx, int uidx) Removes an arrow from v to u.- Parameters:
vidx- index of vuidx- index of u
-
buildRemoveArrowAt
protected void buildRemoveArrowAt(int vidx, int i) Removes the i-th arrow of vertex v.- Parameters:
vidx- index of vi- the i-th arrow of the vertex
-
getArrowCount
public int getArrowCount()Description copied from interface:IndexedDirectedGraphReturns the number of arrows.- Specified by:
getArrowCountin interfaceIndexedDirectedGraph- Returns:
- arrow count
-
getNextAsInt
public int getNextAsInt(int v, int index) Description copied from interface:IndexedDirectedGraphReturns thei-th next vertex ofv.- Specified by:
getNextAsIntin interfaceIndexedDirectedGraph- Parameters:
v- a vertex indexindex- the index of the desired next vertex,i ∈ {0, ..., getNextCount(v) -1 }.- Returns:
- the vertex index of the i-th next vertex of v.
-
getNextCount
public int getNextCount(int v) Description copied from interface:IndexedDirectedGraphReturns the number of next vertices of v.- Specified by:
getNextCountin interfaceIndexedDirectedGraph- Parameters:
v- a vertex- Returns:
- the number of next vertices of v.
-
getPrevAsInt
public int getPrevAsInt(int v, int i) Description copied from interface:IndexedBidiGraphReturns thei-th previous vertex ofv.- Specified by:
getPrevAsIntin interfaceIndexedBidiGraph- Parameters:
v- index of vertex vi- index of ingoing arrow- Returns:
- the vertex index of the ingoing arrow
-
getPrevCount
public int getPrevCount(int v) Description copied from interface:IndexedBidiGraphReturns the number of direct predecessor vertices of v.- Specified by:
getPrevCountin interfaceIndexedBidiGraph- Parameters:
v- index of vertex v- Returns:
- the number of next vertices of v.
-
getVertexCount
public int getVertexCount()Description copied from interface:IndexedDirectedGraphReturns the number of verticesV.- Specified by:
getVertexCountin interfaceIndexedDirectedGraph- Returns:
- vertex count
-