- 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, n
Fields inherited from interface org.jgrapht.Graph
DEFAULT_EDGE_WEIGHT
-
Constructor Summary
ConstructorDescriptionImmutableUndirectedBigGraphAdapter
(it.unimi.dsi.big.webgraph.ImmutableGraph immutableGraph) Creates an adapter for an undirected (i.e., symmetric) big immutable graph. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsEdge
(it.unimi.dsi.fastutil.longs.LongLongSortedPair e) Returnstrue
if this graph contains the specified edge.copy()
int
Returns 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.double
getEdgeWeight
(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.int
inDegreeOf
(Long vertex) Returns the "in degree" of the specified vertex.GraphIterables<Long,
it.unimi.dsi.fastutil.longs.LongLongSortedPair> Access the graph using theGraphIterables
interface.protected it.unimi.dsi.fastutil.longs.LongLongSortedPair
makeEdge
(long x, long y) int
outDegreeOf
(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.boolean
removeEdge
(it.unimi.dsi.fastutil.longs.LongLongSortedPair e) Removes the specified edge from the graph.it.unimi.dsi.fastutil.longs.LongLongSortedPair
removeEdge
(Long sourceVertex, Long targetVertex) Removes an edge going from source vertex to target vertex, if such vertices and such edge exist in this graph.boolean
removeVertex
(Long v) Removes the specified vertex from this graph including all its touching edges if present.void
setEdgeWeight
(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, getVertexSupplier
Methods inherited from class org.jgrapht.graph.AbstractGraph
assertVertexExist, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toString, toStringFromSets
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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:
makeEdge
in classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
-
containsEdge
public boolean containsEdge(it.unimi.dsi.fastutil.longs.LongLongSortedPair e) Description copied from interface:Graph
Returnstrue
if this graph contains the specified edge. More formally, returnstrue
if and only if this graph contains an edgee2
such thate.equals(e2)
. If the specified edge isnull
returnsfalse
.- Specified by:
containsEdge
in interfaceGraph<Long,
it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Parameters:
e
- edge whose presence in this graph is to be tested.- Returns:
true
if this graph contains the specified edge.
-
edgeSet
Description copied from interface:Graph
Returns 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: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".
-
edgesOf
Description copied from interface:Graph
Returns 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:Graph
Returns 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:
inDegreeOf
in 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:Graph
Returns 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:
incomingEdgesOf
in 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:Graph
Returns 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:
outDegreeOf
in 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:Graph
Returns 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:
outgoingEdgesOf
in 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:Graph
Removes an edge going from source vertex to target vertex, if such vertices and such edge exist in this graph. Returns the edge if removed ornull
otherwise.- Specified by:
removeEdge
in interfaceGraph<Long,
it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
removeEdge
in 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
null
if no edge removed.
-
removeEdge
public boolean removeEdge(it.unimi.dsi.fastutil.longs.LongLongSortedPair e) Description copied from interface:Graph
Removes the specified edge from the graph. Removes the specified edge from this graph if it is present. More formally, removes an edgee2
such thate2.equals(e)
, if the graph contains such edge. Returnstrue
if the graph contained the specified edge. (The graph will not contain the specified edge once the call returns).If the specified edge is
null
returnsfalse
.- Specified by:
removeEdge
in interfaceGraph<Long,
it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
removeEdge
in classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
- Parameters:
e
- edge to be removed from this graph, if present.- Returns:
true
if and only if the graph contained the specified edge.
-
removeVertex
Description copied from interface:Graph
Removes the specified vertex from this graph including all its touching edges if present. More formally, if the graph contains a vertexu
such thatu.equals(v)
, the call removes all edges that touchu
and then removesu
itself. If no suchu
is found, the call leaves the graph unchanged. Returnstrue
if the graph contained the specified vertex. (The graph will not contain the specified vertex once the call returns).If the specified vertex is
null
returnsfalse
.- Specified by:
removeVertex
in interfaceGraph<Long,
it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
removeVertex
in classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
- Parameters:
v
- vertex to be removed from this graph, if present.- Returns:
true
if the graph contained the specified vertex;false
otherwise.
-
vertexSet
Description copied from interface:Graph
Returns 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:
vertexSet
in interfaceGraph<Long,
it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
vertexSet
in classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
- Returns:
- a set view of the vertices contained in this graph.
-
getEdgeSource
Description copied from interface:Graph
Returns the source vertex of an edge. For an undirected graph, source and target are distinguishable designations (but without any mathematical meaning).- Specified by:
getEdgeSource
in interfaceGraph<Long,
it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
getEdgeSource
in classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
- Parameters:
e
- edge of interest- Returns:
- source vertex
-
getEdgeTarget
Description copied from interface:Graph
Returns the target vertex of an edge. For an undirected graph, source and target are distinguishable designations (but without any mathematical meaning).- Specified by:
getEdgeTarget
in interfaceGraph<Long,
it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
getEdgeTarget
in 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:Graph
Returns 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:
getEdgeWeight
in interfaceGraph<Long,
it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
getEdgeWeight
in 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:Graph
Assigns a weight to an edge.- Specified by:
setEdgeWeight
in interfaceGraph<Long,
it.unimi.dsi.fastutil.longs.LongLongSortedPair> - Overrides:
setEdgeWeight
in classAbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
- Parameters:
e
- edge on which to set weightweight
- new weight for edge
-
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. -
copy
- Specified by:
copy
in interfaceit.unimi.dsi.lang.FlyweightPrototype<ImmutableUndirectedBigGraphAdapter>
-
iterables
Description copied from interface:Graph
Access the graph using theGraphIterables
interface. 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.
-