Class ImmutableAttributed32BitIndexedDirectedGraph<V,A>

java.lang.Object
org.jhotdraw8.graph.ImmutableAttributed32BitIndexedDirectedGraph<V,A>
Type Parameters:
V - the vertex data type
A - the arrow data type
All Implemented Interfaces:
AttributedIndexedDirectedGraph<V,A>, BareDirectedGraph<V,A>, BareDirectedVertexGraph<V>, DirectedGraph<V,A>, IndexedDirectedGraph

public class ImmutableAttributed32BitIndexedDirectedGraph<V,A> extends Object implements AttributedIndexedDirectedGraph<V,A>, DirectedGraph<V,A>
ImmutableDirectedGraph. Uses int-arrays for storage.

Supports up to 2^31 - 1 vertices.

Uses a representation that is similar to a compressed row storage for matrices (CRS). A directed graph is represented with 4 arrays: nextOffset, next, nextArrows, and vertices.

nextOffset
Holds for each vertex v, the offset into the arrays next, and nextArrows. The data for vertex v can be found in these arrays in the elements from nextOffset[v](inclusive) to nextOffset[v + 1] (exclusive).
next
Holds for each arrow from a vertex v to a vertex u the index of u.
nextArrows
Holds for each arrow from a vertex v to a vertex u the data associated to the arrow.
vertices
Holds for each vertex v the data associated to the vertex.
Author:
Werner Randelshofer
  • Field Details

    • next

      protected final int @NonNull [] next
      Holds the indices to the next vertices.

      The indices are stored in consecutive runs for each vertex, starting at the offset given by nextOffset.

      Given vertex index vi < nextOffset.length - 1
      then
      offset = nextOffset[vi] count = nextOffset[vi+1] - offset

      Given vertex index vi == nextOffset.length - 1
      then
      offset = nextOffset[vi] count = nextOffset.length - offset

    • nextOffset

      protected final int @NonNull [] nextOffset
      Holds offsets into the next table and the nextArrows table.

      Given vertex index vi,
      nextOffset[vi] yields the offset ai in the tables next table and the nextArrows.

      Given vertex index vi < nextOffset.length - 1,
      nextOffset[vi+1]) - nextOffset[vi] yields the number of outgoing arrows of that vertex.

      Given vertex index vi == nextOffset.length - 1,
      nextOffset.length - nextOffset[vi] yields the number of outgoing arrows of that vertex.

    • nextArrows

      protected final @NonNull A @NonNull [] nextArrows
      Holds the arrow objects.

      The arrows are stored in consecutive runs for each vertex, starting at the offset given by nextOffset.

      See next.

    • vertices

      protected final @NonNull V @NonNull [] vertices
      Holds the vertex objects.

      Given vertex index vi,
      vertices[vi| yields the vertex v.

    • vertexToIndexMap

      protected final @NonNull Map<V,Integer> vertexToIndexMap
      Maps vertices the vertex indices.

      Given vertex v,
      vertexToIndexMap.get(v) yields the vertex index vi.

  • Constructor Details

    • ImmutableAttributed32BitIndexedDirectedGraph

      public ImmutableAttributed32BitIndexedDirectedGraph(@NonNull AttributedIndexedDirectedGraph<V,A> graph)
      Creates a new instance from the specified graph.
      Parameters:
      graph - a graph
    • ImmutableAttributed32BitIndexedDirectedGraph

      public ImmutableAttributed32BitIndexedDirectedGraph(@NonNull DirectedGraph<V,A> graph)
      Creates a new instance from the specified graph.
      Parameters:
      graph - a graph
  • Method Details