Class AbstractMutableIndexedBidiGraph

java.lang.Object
org.jhotdraw8.graph.AbstractMutableIndexedBidiGraph
All Implemented Interfaces:
IndexedBidiGraph, IndexedDirectedGraph

public abstract class AbstractMutableIndexedBidiGraph extends Object implements IndexedBidiGraph
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 Details

    • AbstractMutableIndexedBidiGraph

      public AbstractMutableIndexedBidiGraph()
    • AbstractMutableIndexedBidiGraph

      public AbstractMutableIndexedBidiGraph(int vertexCount)
    • AbstractMutableIndexedBidiGraph

      public AbstractMutableIndexedBidiGraph(@NonNull IndexedDirectedGraph g)
  • 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 v
      uidx - index of u
    • buildRemoveArrow

      protected void buildRemoveArrow(int vidx, int uidx)
      Removes an arrow from v to u.
      Parameters:
      vidx - index of v
      uidx - index of u
    • buildRemoveArrowAt

      protected void buildRemoveArrowAt(int vidx, int i)
      Removes the i-th arrow of vertex v.
      Parameters:
      vidx - index of v
      i - the i-th arrow of the vertex
    • getArrowCount

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

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

      public int getPrevAsInt(int v, int i)
      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
      i - 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.
    • getVertexCount

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