Class AbstractSuccinctDirectedGraph<E>

Type Parameters:
E - the graph edge type
All Implemented Interfaces:
Serializable, Graph<Integer,E>
Direct Known Subclasses:
SuccinctDirectedGraph, SuccinctIntDirectedGraph

public abstract class AbstractSuccinctDirectedGraph<E> extends AbstractSuccinctGraph<E>
An abstract base class for all succinct directed implementations.

Two subclasses, AbstractSuccinctDirectedGraph.CumulativeSuccessors and AbstractSuccinctDirectedGraph.CumulativeDegrees, generate the monotone lists that will be encoded using the Elias–Fano representation.

First, we store the monotone lists of cumulative outdegrees and indegrees.

Then, we store the outgoing edges x → y as a monotone sequence using the encoding x2⌈log n + y. At that point the k-th edge can be obtained by retrieving the k-th element of the sequence and some bit shifting (the encoding xn + y would be slightly more compact, but much slower to decode). Since we know the list of cumulative outdegrees, we know which range of indices corresponds to the edges outgoing from each vertex. If we need to know whether x → y is an edge we just look for x2⌈log n + y in the sequence.

Finally, we store incoming edges y → x again as a monotone sequence using the encoding xn + y - e, where e is the index of the edge in lexicographical order. In this case we just need to be able to recover the edges associated with a vertex, so we can use a more compact format.

However, in the case of a SuccinctIntDirectedGraph after retrieving the source and target of an incoming edge we need to index it. The slow indexing of the incoming edges is the reason why a SuccinctIntDirectedGraph enumerates incoming edges very slowly, whereas a SuccinctDirectedGraph does not.

See Also:
  • Constructor Details

    • AbstractSuccinctDirectedGraph

      public AbstractSuccinctDirectedGraph(int n, int m)
  • Method Details

    • degreeOf

      public int degreeOf(Integer vertex)
      Description copied from interface: Graph
      Returns the degree of the specified vertex.

      A degree of a vertex in an undirected graph is the number of edges touching that vertex. Edges with same source and target vertices (self-loops) are counted twice.

      In directed graphs this method returns the sum of the "in degree" and the "out degree".

      Parameters:
      vertex - vertex whose degree is to be calculated.
      Returns:
      the degree of the specified vertex.
    • getType

      public GraphType getType()
      Description copied from interface: Graph
      Get the graph type. The graph type can be used to query for additional metadata such as whether the graph supports directed or undirected edges, self-loops, multiple (parallel) edges, weights, etc.
      Returns:
      the graph type