- All Implemented Interfaces:
it.unimi.dsi.lang.FlyweightPrototype<ImmutableUndirectedBigGraphAdapter>,Graph<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair>
ImmutableGraph.
This class is equivalent to ImmutableUndirectedGraphAdapter, except that nodes are
instances of Long, and edges are instances of LongLongSortedPair.
If necessary, you can adapt a standard WebGraph graph using the suitable wrapper.
- Author:
- Sebastiano Vigna
- See Also:
-
Field Summary
Fields inherited from class org.jgrapht.webgraph.AbstractImmutableBigGraphAdapter
immutableGraph, m, nFields inherited from interface org.jgrapht.Graph
DEFAULT_EDGE_WEIGHT -
Constructor Summary
ConstructorsConstructorDescriptionImmutableUndirectedBigGraphAdapter(it.unimi.dsi.big.webgraph.ImmutableGraph immutableGraph) Creates an adapter for an undirected (i.e., symmetric) big immutable graph. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsEdge(it.unimi.dsi.fastutil.longs.LongLongSortedPair e) Returnstrueif this graph contains the specified edge.copy()intReturns the degree of the specified vertex.Set<it.unimi.dsi.fastutil.longs.LongLongSortedPair>edgeSet()Returns a set of the edges contained in this graph.Set<it.unimi.dsi.fastutil.longs.LongLongSortedPair>Returns a set of all edges touching the specified vertex.getEdgeSource(it.unimi.dsi.fastutil.longs.LongLongSortedPair e) Returns the source vertex of an edge.getEdgeTarget(it.unimi.dsi.fastutil.longs.LongLongSortedPair e) Returns the target vertex of an edge.doublegetEdgeWeight(it.unimi.dsi.fastutil.longs.LongLongSortedPair e) Returns the weight assigned to a given edge.getType()Get the graph type.Set<it.unimi.dsi.fastutil.longs.LongLongSortedPair>incomingEdgesOf(Long vertex) Returns a set of all edges incoming into the specified vertex.intinDegreeOf(Long vertex) Returns the "in degree" of the specified vertex.GraphIterables<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair> Access the graph using theGraphIterablesinterface.protected it.unimi.dsi.fastutil.longs.LongLongSortedPairmakeEdge(long x, long y) intoutDegreeOf(Long vertex) Returns the "out degree" of the specified vertex.Set<it.unimi.dsi.fastutil.longs.LongLongSortedPair>outgoingEdgesOf(Long vertex) Returns a set of all edges outgoing from the specified vertex.booleanremoveEdge(it.unimi.dsi.fastutil.longs.LongLongSortedPair e) Removes the specified edge from the graph.it.unimi.dsi.fastutil.longs.LongLongSortedPairremoveEdge(Long sourceVertex, Long targetVertex) Removes an edge going from source vertex to target vertex, if such vertices and such edge exist in this graph.booleanremoveVertex(Long v) Removes the specified vertex from this graph including all its touching edges if present.voidsetEdgeWeight(it.unimi.dsi.fastutil.longs.LongLongSortedPair e, double weight) Assigns a weight to an edge.Returns a set of the vertices contained in this graph.Methods inherited from class org.jgrapht.webgraph.AbstractImmutableBigGraphAdapter
addEdge, addEdge, addVertex, addVertex, containsEdge, containsEdgeFast, containsVertex, getAllEdges, getEdge, getEdgeSupplier, getVertexSupplierMethods inherited from class org.jgrapht.graph.AbstractGraph
assertVertexExist, 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
setEdgeWeight
-
Constructor Details
-
ImmutableUndirectedBigGraphAdapter
public ImmutableUndirectedBigGraphAdapter(it.unimi.dsi.big.webgraph.ImmutableGraph immutableGraph) Creates an adapter for an undirected (i.e., symmetric) big immutable graph.It is responsibility of the caller that the provided graph has is symmetric (for each arc x → y there is an arc y → x). If this property is not true, results will be unpredictable.
- Parameters:
immutableGraph- a symmetric big immutable graph.
-
-
Method Details
-
makeEdge
protected it.unimi.dsi.fastutil.longs.LongLongSortedPair makeEdge(long x, long y) - Specified by:
makeEdgein classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
-
containsEdge
public boolean containsEdge(it.unimi.dsi.fastutil.longs.LongLongSortedPair e) Description copied from interface:GraphReturnstrueif this graph contains the specified edge. More formally, returnstrueif and only if this graph contains an edgee2such thate.equals(e2). If the specified edge isnullreturnsfalse.- Specified by:
containsEdgein interfaceGraph<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Parameters:
e- edge whose presence in this graph is to be tested.- Returns:
trueif this graph contains the specified edge.
-
edgeSet
Description copied from interface:GraphReturns a set of the edges contained in this graph. The set is backed by the graph, so changes to the graph are reflected in the set. If the graph is modified while an iteration over the set is in progress, the results of the iteration are undefined.The graph implementation may maintain a particular set ordering (e.g. via
LinkedHashSet) for deterministic iteration, but this is not required. It is the responsibility of callers who rely on this behavior to only use graph implementations which support it. -
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".
-
edgesOf
Description copied from interface:GraphReturns a set of all edges touching the specified vertex. If no edges are touching the specified vertex returns an empty set. -
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.
- Specified by:
inDegreeOfin interfaceGraph<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Parameters:
vertex- vertex whose degree is to be calculated.- Returns:
- the degree of the specified vertex.
-
incomingEdgesOf
Description copied from interface:GraphReturns a set of all edges incoming into the specified vertex.In the case of undirected graphs this method returns all edges touching the vertex, thus, some of the returned edges may have their source and target vertices in the opposite order.
- Specified by:
incomingEdgesOfin interfaceGraph<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Parameters:
vertex- the vertex for which the list of incoming edges to be returned.- Returns:
- a set of all edges incoming into 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.
- Specified by:
outDegreeOfin interfaceGraph<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Parameters:
vertex- vertex whose degree is to be calculated.- Returns:
- the degree of the specified vertex.
-
outgoingEdgesOf
Description copied from interface:GraphReturns a set of all edges outgoing from the specified vertex.In the case of undirected graphs this method returns all edges touching the vertex, thus, some of the returned edges may have their source and target vertices in the opposite order.
- Specified by:
outgoingEdgesOfin interfaceGraph<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Parameters:
vertex- the vertex for which the list of outgoing edges to be returned.- Returns:
- a set of all edges outgoing from the specified vertex.
-
removeEdge
public it.unimi.dsi.fastutil.longs.LongLongSortedPair removeEdge(Long sourceVertex, Long targetVertex) Description copied from interface:GraphRemoves an edge going from source vertex to target vertex, if such vertices and such edge exist in this graph. Returns the edge if removed ornullotherwise.- Specified by:
removeEdgein interfaceGraph<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
removeEdgein classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>- Parameters:
sourceVertex- source vertex of the edge.targetVertex- target vertex of the edge.- Returns:
- The removed edge, or
nullif no edge removed.
-
removeEdge
public boolean removeEdge(it.unimi.dsi.fastutil.longs.LongLongSortedPair e) Description copied from interface:GraphRemoves the specified edge from the graph. Removes the specified edge from this graph if it is present. More formally, removes an edgee2such thate2.equals(e), if the graph contains such edge. Returnstrueif the graph contained the specified edge. (The graph will not contain the specified edge once the call returns).If the specified edge is
nullreturnsfalse.- Specified by:
removeEdgein interfaceGraph<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
removeEdgein classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>- Parameters:
e- edge to be removed from this graph, if present.- Returns:
trueif and only if the graph contained the specified edge.
-
removeVertex
Description copied from interface:GraphRemoves the specified vertex from this graph including all its touching edges if present. More formally, if the graph contains a vertexusuch thatu.equals(v), the call removes all edges that touchuand then removesuitself. If no suchuis found, the call leaves the graph unchanged. Returnstrueif the graph contained the specified vertex. (The graph will not contain the specified vertex once the call returns).If the specified vertex is
nullreturnsfalse.- Specified by:
removeVertexin interfaceGraph<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
removeVertexin classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>- Parameters:
v- vertex to be removed from this graph, if present.- Returns:
trueif the graph contained the specified vertex;falseotherwise.
-
vertexSet
Description copied from interface:GraphReturns a set of the vertices contained in this graph. The set is backed by the graph, so changes to the graph are reflected in the set. If the graph is modified while an iteration over the set is in progress, the results of the iteration are undefined.The graph implementation may maintain a particular set ordering (e.g. via
LinkedHashSet) for deterministic iteration, but this is not required. It is the responsibility of callers who rely on this behavior to only use graph implementations which support it.- Specified by:
vertexSetin interfaceGraph<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
vertexSetin classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>- Returns:
- a set view of the vertices contained in this graph.
-
getEdgeSource
Description copied from interface:GraphReturns the source vertex of an edge. For an undirected graph, source and target are distinguishable designations (but without any mathematical meaning).- Specified by:
getEdgeSourcein interfaceGraph<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
getEdgeSourcein classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>- Parameters:
e- edge of interest- Returns:
- source vertex
-
getEdgeTarget
Description copied from interface:GraphReturns the target vertex of an edge. For an undirected graph, source and target are distinguishable designations (but without any mathematical meaning).- Specified by:
getEdgeTargetin interfaceGraph<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
getEdgeTargetin classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>- Parameters:
e- edge of interest- Returns:
- target vertex
-
getEdgeWeight
public double getEdgeWeight(it.unimi.dsi.fastutil.longs.LongLongSortedPair e) Description copied from interface:GraphReturns the weight assigned to a given edge. Unweighted graphs return 1.0 (as defined byGraph.DEFAULT_EDGE_WEIGHT), allowing weighted-graph algorithms to apply to them when meaningful.- Specified by:
getEdgeWeightin interfaceGraph<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
getEdgeWeightin classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>- Parameters:
e- edge of interest- Returns:
- edge weight
-
setEdgeWeight
public void setEdgeWeight(it.unimi.dsi.fastutil.longs.LongLongSortedPair e, double weight) Description copied from interface:GraphAssigns a weight to an edge.- Specified by:
setEdgeWeightin interfaceGraph<Long,it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
setEdgeWeightin classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>- Parameters:
e- edge on which to set weightweight- new weight for edge
-
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. -
copy
- Specified by:
copyin interfaceit.unimi.dsi.lang.FlyweightPrototype<ImmutableUndirectedBigGraphAdapter>
-
iterables
Description copied from interface:GraphAccess the graph using theGraphIterablesinterface. This allows accessing graphs without the restrictions imposed by 32-bit arithmetic. Moreover, graph implementations are free to implement this interface without explicitly materializing intermediate results.
-