- Type Parameters:
E- the graph edge type
- All Implemented Interfaces:
Serializable,Graph<Integer,E>
- Direct Known Subclasses:
SuccinctDirectedGraph,SuccinctIntDirectedGraph
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classIterates over the cumulative degrees (starts with a zero).protected static final classTurns all edges x → y into a monotone sequence using the encoding x2⌈log n⌉ + y, or the encoding xn + y - e, where e is the index of the edge in lexicographical order, depending on the value of thestrictparameter. -
Field Summary
Fields inherited from class org.jgrapht.sux4j.AbstractSuccinctGraph
m, n, sourceShift, targetMask, UNMODIFIABLEFields inherited from interface org.jgrapht.Graph
DEFAULT_EDGE_WEIGHT -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.jgrapht.sux4j.AbstractSuccinctGraph
addEdge, addEdge, addVertex, addVertex, assertVertexExist, containsVertex, getAllEdges, getEdgeSupplier, getEdgeWeight, getVertexSupplier, removeEdge, removeEdge, removeVertex, setEdgeWeight, vertexSetMethods inherited from class org.jgrapht.graph.AbstractGraph
containsEdge, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toString, toStringFromSetsMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jgrapht.Graph
containsEdge, edgeSet, edgesOf, getEdge, getEdgeSource, getEdgeTarget, incomingEdgesOf, inDegreeOf, iterables, outDegreeOf, outgoingEdgesOf, setEdgeWeight
-
Constructor Details
-
AbstractSuccinctDirectedGraph
public AbstractSuccinctDirectedGraph(int n, int m)
-
-
Method Details
-
degreeOf
Description copied from interface:GraphReturns 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
Description copied from interface:GraphGet 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
-