Class ChunkedMutableIndexedBidiGraph

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 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:
      addArrowAsInt in interface MutableIndexedBidiGraph
      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:
      addArrowAsInt in interface MutableIndexedBidiGraph
      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: MutableIndexedBidiGraph
      Adds a vertex to the graph.
      Specified by:
      addVertexAsInt in interface MutableIndexedBidiGraph
    • addVertexAsInt

      public void addVertexAsInt(int v)
      Description copied from interface: MutableIndexedBidiGraph
      Adds a vertex at the specified index to the graph.
      Specified by:
      addVertexAsInt in interface MutableIndexedBidiGraph
      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 vertex
      dfs - whether depth-first-search should be used instead of breadth-first-search
      visited - 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 vertex
      dfs - whether depth-first-search should be used instead of breadth-first-search
      visited - 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 vertex
      dfs - whether depth-first-search should be used instead of breadth-first-search
      visited - 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 vertex
      dfs - whether depth-first-search should be used instead of breadth-first-search
      visited - 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: IndexedDirectedGraph
      Returns the index of vertex b.
      Specified by:
      findIndexOfNextAsInt in interface IndexedDirectedGraph
      Parameters:
      v - a vertex
      u - 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: IndexedBidiGraph
      Returns the index of the arrow from v to u in the list of next-vertices from v.
      Specified by:
      findIndexOfPrevAsInt in interface IndexedBidiGraph
      Parameters:
      v - vertex v
      u - vertex u
      Returns:
      index of vertex u in the list of next-vertices from v. Returns a value < 0 if u is not in the list.
    • getArrowCount

      public int getArrowCount()
      Description copied from interface: IndexedDirectedGraph
      Returns the number of arrows.
      Specified by:
      getArrowCount in interface IndexedDirectedGraph
      Returns:
      arrow count
    • getNextArrowAsInt

      public int getNextArrowAsInt(int v, int i)
      Description copied from interface: IndexedDirectedGraph
      Returns the i-th next arrow of v.
      Specified by:
      getNextArrowAsInt in interface IndexedDirectedGraph
      Specified by:
      getNextArrowAsInt in interface IntAttributedIndexedDirectedGraph
      Parameters:
      v - a vertex index
      i - 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: IndexedDirectedGraph
      Returns the i-th next vertex of v.
      Specified by:
      getNextAsInt in interface IndexedDirectedGraph
      Parameters:
      v - a vertex index
      i - 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: IndexedDirectedGraph
      Returns the number of next vertices of v.
      Specified by:
      getNextCount in interface IndexedDirectedGraph
      Parameters:
      v - a vertex
      Returns:
      the number of next vertices of v.
    • getPrevArrowAsInt

      public int getPrevArrowAsInt(int v, int i)
      Description copied from interface: IndexedBidiGraph
      Returns the arrow data of the i-th ingoing arrow to v.
      Specified by:
      getPrevArrowAsInt in interface IndexedBidiGraph
      Parameters:
      v - index of vertex v
      i - index of ingoing arrow
      Returns:
      the arrow data of the ingoing arrow
    • getPrevAsInt

      public int getPrevAsInt(int v, int k)
      Description copied from interface: IndexedBidiGraph
      Returns the i-th previous vertex of v.
      Specified by:
      getPrevAsInt in interface IndexedBidiGraph
      Parameters:
      v - index of vertex v
      k - index of ingoing arrow
      Returns:
      the vertex index of the ingoing arrow
    • getPrevCount

      public int getPrevCount(int v)
      Description copied from interface: IndexedBidiGraph
      Returns the number of direct predecessor vertices of v.
      Specified by:
      getPrevCount in interface IndexedBidiGraph
      Parameters:
      v - index of vertex v
      Returns:
      the number of next vertices of v.
    • getVertexDataAsInt

      public int getVertexDataAsInt(int v)
      Description copied from interface: IntAttributedIndexedDirectedGraph
      Returns the data of the specified vertex.
      Specified by:
      getVertexDataAsInt in interface IntAttributedIndexedDirectedGraph
      Parameters:
      v - a vertex
      Returns:
      the vertex data
    • getVertexCount

      public int getVertexCount()
      Description copied from interface: IndexedDirectedGraph
      Returns the number of vertices V.
      Specified by:
      getVertexCount in interface IndexedDirectedGraph
      Returns:
      vertex count
    • removeAllNextAsInt

      public void removeAllNextAsInt(int v)
      Description copied from interface: MutableIndexedBidiGraph
      Removes all arrows starting at the specified vertex.
      Specified by:
      removeAllNextAsInt in interface MutableIndexedBidiGraph
      Parameters:
      v - index of vertex 'v'
    • removeAllPrevAsInt

      public void removeAllPrevAsInt(int v)
      Description copied from interface: MutableIndexedBidiGraph
      Removes all arrows ending at the specified vertex.
      Specified by:
      removeAllPrevAsInt in interface MutableIndexedBidiGraph
      Parameters:
      v - index of vertex 'v'
    • removeNextAsInt

      public void removeNextAsInt(int v, int index)
      Description copied from interface: MutableIndexedBidiGraph
      Removes the i-th arrow starting at vertex 'v'
      Specified by:
      removeNextAsInt in interface MutableIndexedBidiGraph
      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: MutableIndexedBidiGraph
      Removes the i-th arrow ending at vertex 'v'
      Specified by:
      removePrevAsInt in interface MutableIndexedBidiGraph
      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: MutableIndexedBidiGraph
      Removes vertex 'v'
      Specified by:
      removeVertexAsInt in interface MutableIndexedBidiGraph
      Parameters:
      v - index of vertex 'v'
    • setVertexDataAsInt

      public void setVertexDataAsInt(int v, int data)
    • getChunkFactory

      public @NonNull BiFunction<Integer,Integer,GraphChunk> getChunkFactory()
    • setChunkFactory

      public void setChunkFactory(@NonNull BiFunction<Integer,Integer,GraphChunk> chunkFactory)