java.lang.Object
org.jhotdraw8.graph.ChunkedMutableIndexedBidiGraph
- All Implemented Interfaces:
IndexedBidiGraph,IndexedDirectedGraph,IntAttributedIndexedBidiGraph,IntAttributedIndexedDirectedGraph,MutableIndexedBidiGraph
public class ChunkedMutableIndexedBidiGraph
extends Object
implements MutableIndexedBidiGraph, IntAttributedIndexedBidiGraph
A mutable indexed bi-directional graph. The data structure of the graph
is split up into
GraphChunks.-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new insChunkedMutableIndexedBidiGraph(int chunkSize, int initialArityCapacity) ChunkedMutableIndexedBidiGraph(int chunkSize, int initialArityCapacity, @NonNull BiFunction<Integer, Integer, GraphChunk> chunkFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddArrowAsInt(int v, int u) Adds the arrow if it is absent.voidaddArrowAsInt(int v, int u, int data) Adds the arrow if it is absent.booleanaddArrowIfAbsentAsInt(int v, int u, int data) Adds the arrow if its absent, updates the arrow data if the arrow is present.booleanaddOrUpdateArrowAsInt(int v, int u, int data) Adds the arrow if its absent, updates the arrow data if the arrow is present.voidAdds a vertex to the graph.voidaddVertexAsInt(int v) Adds a vertex at the specified index to the graph.voidclear()Removes all vertices and arrows from the graph.intfindIndexOfNextAsInt(int v, int u) Returns the index of vertex b.intfindIndexOfPrevAsInt(int v, int u) Returns the index of the arrow fromvtouin the list of next-vertices fromv.intReturns the number of arrows.intgetNextArrowAsInt(int v, int i) Returns thei-th next arrow ofv.intgetNextAsInt(int v, int i) Returns thei-th next vertex ofv.intgetNextCount(int v) Returns the number of next vertices of v.intgetPrevArrowAsInt(int v, int i) Returns the arrow data of thei-th ingoing arrow tov.intgetPrevAsInt(int v, int k) Returns thei-th previous vertex ofv.intgetPrevCount(int v) Returns the number of direct predecessor vertices of v.intReturns the number of verticesV.intgetVertexDataAsInt(int v) Returns the data of the specified vertex.voidremoveAllNextAsInt(int v) Removes all arrows starting at the specified vertex.voidremoveAllPrevAsInt(int v) Removes all arrows ending at the specified vertex.voidremoveNextAsInt(int v, int index) Removes the i-th arrow starting at vertex 'v'voidremovePrevAsInt(int v, int index) Removes the i-th arrow ending at vertex 'v'voidremoveVertexAsInt(int v) Removes vertex 'v'searchNextVertexData(int v, boolean dfs, @NonNull AddToIntSet visited) Searches for successor vertex data of the specified vertex.searchNextVertices(int v, boolean dfs, @NonNull AddToIntSet visited) Searches for successor vertices of the specified vertex.searchPrevVertexData(int v, boolean dfs, @NonNull AddToIntSet visited) Searches for predecessor vertex data of the specified vertex.searchPrevVertices(int vidx, boolean dfs, @NonNull AddToIntSet visited) Searches for predecessor vertices of the specified vertex.voidsetChunkFactory(@NonNull BiFunction<Integer, Integer, GraphChunk> chunkFactory) voidsetVertexDataAsInt(int v, int data) 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
isPrevAsInt, prevVerticesEnumeratorMethods inherited from interface org.jhotdraw8.graph.IndexedDirectedGraph
isNextAsInt, nextVerticesEnumeratorMethods inherited from interface org.jhotdraw8.graph.MutableIndexedBidiGraph
removeArrowAsInt
-
Constructor Details
-
ChunkedMutableIndexedBidiGraph
public ChunkedMutableIndexedBidiGraph()Creates a new ins -
ChunkedMutableIndexedBidiGraph
public ChunkedMutableIndexedBidiGraph(int chunkSize, int initialArityCapacity) -
ChunkedMutableIndexedBidiGraph
public ChunkedMutableIndexedBidiGraph(int chunkSize, int initialArityCapacity, @NonNull BiFunction<Integer, Integer, GraphChunk> chunkFactory)
-
-
Method Details
-
addArrowAsInt
public void addArrowAsInt(int v, int u) Adds the arrow if it is absent.- Specified by:
addArrowAsIntin interfaceMutableIndexedBidiGraph- Parameters:
v- index of vertex 'v'u- index of vertex 'u'
-
addArrowAsInt
public void addArrowAsInt(int v, int u, int data) Adds the arrow if it is absent.- Specified by:
addArrowAsIntin interfaceMutableIndexedBidiGraph- Parameters:
v- index of vertex 'v'u- index of vertex 'u'data- the arrow data
-
addArrowIfAbsentAsInt
public boolean addArrowIfAbsentAsInt(int v, int u, int data) Adds the arrow if its absent, updates the arrow data if the arrow is present. Does nothing if there is already an arrow.- Parameters:
v- index of vertex 'v'u- index of vertex 'u'data- the arrow data- Returns:
- true if the arrow was absent
-
addOrUpdateArrowAsInt
public boolean addOrUpdateArrowAsInt(int v, int u, int data) Adds the arrow if its absent, updates the arrow data if the arrow is present.- Parameters:
v- index of vertex 'v'u- index of vertex 'u'data- the arrow data- Returns:
- true if the arrow was absent
-
addVertexAsInt
public void addVertexAsInt()Description copied from interface:MutableIndexedBidiGraphAdds a vertex to the graph.- Specified by:
addVertexAsIntin interfaceMutableIndexedBidiGraph
-
addVertexAsInt
public void addVertexAsInt(int v) Description copied from interface:MutableIndexedBidiGraphAdds a vertex at the specified index to the graph.- Specified by:
addVertexAsIntin interfaceMutableIndexedBidiGraph- Parameters:
v- index of vertex 'v'
-
searchPrevVertices
public @NonNull Enumerator.OfInt searchPrevVertices(int vidx, boolean dfs, @NonNull AddToIntSet visited) Searches for predecessor vertices of the specified vertex.- Parameters:
vidx- the index of the vertexdfs- whether depth-first-search should be used instead of breadth-first-searchvisited- the set of visited vertices- Returns:
- the enumerator provides the vertex index
-
searchPrevVertexData
public @NonNull Spliterator.OfLong searchPrevVertexData(int v, boolean dfs, @NonNull AddToIntSet visited) Searches for predecessor vertex data of the specified vertex.- Parameters:
v- a vertexdfs- whether depth-first-search should be used instead of breadth-first-searchvisited- the set of visited vertices- Returns:
- the enumerator provides the vertex data in the 32 high-bits and the vertex index in the 32 low-bits of the long.
-
searchNextVertices
public @NonNull Enumerator.OfInt searchNextVertices(int v, boolean dfs, @NonNull AddToIntSet visited) Searches for successor vertices of the specified vertex.- Parameters:
v- a vertexdfs- whether depth-first-search should be used instead of breadth-first-searchvisited- the set of visited vertices- Returns:
- the enumerator provides the vertex index
-
searchNextVertexData
public @NonNull Spliterator.OfLong searchNextVertexData(int v, boolean dfs, @NonNull AddToIntSet visited) Searches for successor vertex data of the specified vertex.- Parameters:
v- a vertexdfs- whether depth-first-search should be used instead of breadth-first-searchvisited- the set of visited vertices- Returns:
- the enumerator provides the vertex data in the 32 high-bits and the vertex index in the 32 low-bits of the long.
-
clear
public void clear()Removes all vertices and arrows from the graph. -
findIndexOfNextAsInt
public int findIndexOfNextAsInt(int v, int u) Description copied from interface:IndexedDirectedGraphReturns the index of vertex b.- Specified by:
findIndexOfNextAsIntin interfaceIndexedDirectedGraph- Parameters:
v- a vertexu- another vertex- Returns:
- index of vertex b. Returns a value < 0 if b is not a next vertex of a.
-
findIndexOfPrevAsInt
public int findIndexOfPrevAsInt(int v, int u) Description copied from interface:IndexedBidiGraphReturns the index of the arrow fromvtouin the list of next-vertices fromv.- Specified by:
findIndexOfPrevAsIntin interfaceIndexedBidiGraph- Parameters:
v- vertexvu- vertexu- Returns:
- index of vertex
uin the list of next-vertices fromv. Returns a value < 0 ifuis not in the list.
-
getArrowCount
public int getArrowCount()Description copied from interface:IndexedDirectedGraphReturns the number of arrows.- Specified by:
getArrowCountin interfaceIndexedDirectedGraph- Returns:
- arrow count
-
getNextArrowAsInt
public int getNextArrowAsInt(int v, int i) Description copied from interface:IndexedDirectedGraphReturns thei-th next arrow ofv.- Specified by:
getNextArrowAsIntin interfaceIndexedDirectedGraph- Specified by:
getNextArrowAsIntin interfaceIntAttributedIndexedDirectedGraph- Parameters:
v- a vertex indexi- the index of the desired arrow,i ∈ {0, ..., getNextCount(v) -1 }.- Returns:
- the arrow data of the i-th next vertex of v.
-
getNextAsInt
public int getNextAsInt(int v, int i) Description copied from interface:IndexedDirectedGraphReturns thei-th next vertex ofv.- Specified by:
getNextAsIntin interfaceIndexedDirectedGraph- Parameters:
v- a vertex indexi- 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.
-
getPrevArrowAsInt
public int getPrevArrowAsInt(int v, int i) Description copied from interface:IndexedBidiGraphReturns the arrow data of thei-th ingoing arrow tov.- Specified by:
getPrevArrowAsIntin interfaceIndexedBidiGraph- Parameters:
v- index of vertex vi- index of ingoing arrow- Returns:
- the arrow data of the ingoing arrow
-
getPrevAsInt
public int getPrevAsInt(int v, int k) Description copied from interface:IndexedBidiGraphReturns thei-th previous vertex ofv.- Specified by:
getPrevAsIntin interfaceIndexedBidiGraph- Parameters:
v- index of vertex vk- 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.
-
getVertexDataAsInt
public int getVertexDataAsInt(int v) Description copied from interface:IntAttributedIndexedDirectedGraphReturns the data of the specified vertex.- Specified by:
getVertexDataAsIntin interfaceIntAttributedIndexedDirectedGraph- Parameters:
v- a vertex- Returns:
- the vertex data
-
getVertexCount
public int getVertexCount()Description copied from interface:IndexedDirectedGraphReturns the number of verticesV.- Specified by:
getVertexCountin interfaceIndexedDirectedGraph- Returns:
- vertex count
-
removeAllNextAsInt
public void removeAllNextAsInt(int v) Description copied from interface:MutableIndexedBidiGraphRemoves all arrows starting at the specified vertex.- Specified by:
removeAllNextAsIntin interfaceMutableIndexedBidiGraph- Parameters:
v- index of vertex 'v'
-
removeAllPrevAsInt
public void removeAllPrevAsInt(int v) Description copied from interface:MutableIndexedBidiGraphRemoves all arrows ending at the specified vertex.- Specified by:
removeAllPrevAsIntin interfaceMutableIndexedBidiGraph- Parameters:
v- index of vertex 'v'
-
removeNextAsInt
public void removeNextAsInt(int v, int index) Description copied from interface:MutableIndexedBidiGraphRemoves the i-th arrow starting at vertex 'v'- Specified by:
removeNextAsIntin interfaceMutableIndexedBidiGraph- Parameters:
v- index of vertex 'v'index- the index of the arrow starting at 'v'
-
removePrevAsInt
public void removePrevAsInt(int v, int index) Description copied from interface:MutableIndexedBidiGraphRemoves the i-th arrow ending at vertex 'v'- Specified by:
removePrevAsIntin interfaceMutableIndexedBidiGraph- Parameters:
v- index of vertex 'v'index- the index of the arrow ending at 'v'
-
removeVertexAsInt
public void removeVertexAsInt(int v) Description copied from interface:MutableIndexedBidiGraphRemoves vertex 'v'- Specified by:
removeVertexAsIntin interfaceMutableIndexedBidiGraph- Parameters:
v- index of vertex 'v'
-
setVertexDataAsInt
public void setVertexDataAsInt(int v, int data) -
getChunkFactory
-
setChunkFactory
-