- Type Parameters:
E- the graph edge type
- All Implemented Interfaces:
Serializable,Graph<Integer,E>
- Direct Known Subclasses:
SuccinctIntUndirectedGraph,SuccinctUndirectedGraph
Two subclasses, AbstractSuccinctUndirectedGraph.CumulativeSuccessors and AbstractSuccinctUndirectedGraph.CumulativeDegrees, generate the monotone
lists that will be encoded using the Elias–Fano representation.
We use the representation described in AbstractSuccinctDirectedGraph applied to the
directed graph obtained by choosing the direction x → y for
an edge x — y if x ≤ y
(loops are represented twice). Each edge now appears exactly once in the list of outgoing edges,
and thus can be indexed as in the directed base.
The set of vertices adjacent to a given vertex can then be retrieved by enumerating both outgoing and incoming edges, being careful to avoid enumerating twice loops.
However, in the case of a SuccinctIntUndirectedGraph 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 SuccinctIntUndirectedGraph enumerates edges very slowly, whereas a
SuccinctUndirectedGraph 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, x ≤ y, into a monotone sequence using the encoding x2⌈log n⌉ + y, or all edges x — y, x ≥ y, using the encoding xn + y - e, where e is the index of the edge in lexicographical order, depending on the value of thesortedparameter. -
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
Modifier and TypeMethodDescriptionprotected booleancontainsEdge(it.unimi.dsi.sux4j.util.EliasFanoIndexedMonotoneLongBigList successors, int x, int y) getType()Get the graph type.intinDegreeOf(Integer vertex) Returns the "in degree" of the specified vertex.intoutDegreeOf(Integer vertex) Returns the "out degree" of the specified vertex.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, degreeOf, edgeSet, edgesOf, getEdge, getEdgeSource, getEdgeTarget, incomingEdgesOf, iterables, outgoingEdgesOf, setEdgeWeight
-
Constructor Details
-
AbstractSuccinctUndirectedGraph
public AbstractSuccinctUndirectedGraph(int n, int m)
-
-
Method Details
-
inDegreeOf
Description copied from interface:GraphReturns the "in degree" of the specified vertex.The "in degree" of a vertex in a directed graph is the number of inward directed edges from that vertex. See http://mathworld.wolfram.com/Indegree.html.
In the case of undirected graphs this method returns the number of edges touching the vertex. Edges with same source and target vertices (self-loops) are counted twice.
- Parameters:
vertex- vertex whose degree is to be calculated.- Returns:
- the degree of the specified vertex.
-
outDegreeOf
Description copied from interface:GraphReturns the "out degree" of the specified vertex.The "out degree" of a vertex in a directed graph is the number of outward directed edges from that vertex. See http://mathworld.wolfram.com/Outdegree.html.
In the case of undirected graphs this method returns the number of edges touching the vertex. Edges with same source and target vertices (self-loops) are counted twice.
- Parameters:
vertex- vertex whose degree is to be calculated.- Returns:
- the degree of the specified vertex.
-
containsEdge
protected boolean containsEdge(it.unimi.dsi.sux4j.util.EliasFanoIndexedMonotoneLongBigList successors, int x, int y) -
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
-