Interface IEdgeSet
-
- All Superinterfaces:
Collection<Integer>
,EdgeSet<Integer,Integer>
,IntCollection
,IntIterable
,IntSet
,Iterable<Integer>
,Set<Integer>
public interface IEdgeSet extends EdgeSet<Integer,Integer>, IntSet
Set of int graph edges.This interface is a specification of
EdgeSet
forIntGraph
.A set of integers, each represent an edge ID in a graph
IntGraph g = ...; int vertex = ...; for (IEdgeIter eit = g.outEdges(vertex).iterator(); eit.hasNext();) { int e = eit.nextInt(); int u = eit.sourceInt(); int v = eit.targetInt(); assert vertex == u; System.out.println("Out edge of " + vertex + ": " + e + "(" + u + ", " + v + ")"); }
- Author:
- Barak Ugav
- See Also:
IEdgeIter
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static IEdgeSet
allOf(IntGraph g)
Create an edge set object of all the edges in a graph.default IEdgeIter
intIterator()
Return an edge iterator that iterate over the edges in this set.IEdgeIter
iterator()
Return an edge iterator that iterate over the edges in this set.static IEdgeSet
of(IntSet edges, IntGraph g)
Create an edge set object from a plain set of edges.-
Methods inherited from interface java.util.Collection
toArray
-
Methods inherited from interface it.unimi.dsi.fastutil.ints.IntCollection
add, addAll, contains, containsAll, intParallelStream, intSpliterator, intStream, parallelStream, removeAll, removeIf, removeIf, removeIf, retainAll, stream, toArray, toIntArray, toIntArray
-
Methods inherited from interface it.unimi.dsi.fastutil.ints.IntIterable
forEach, forEach, forEach
-
-
-
-
Method Detail
-
iterator
IEdgeIter iterator()
Return an edge iterator that iterate over the edges in this set.- Specified by:
iterator
in interfaceCollection<Integer>
- Specified by:
iterator
in interfaceEdgeSet<Integer,Integer>
- Specified by:
iterator
in interfaceIntCollection
- Specified by:
iterator
in interfaceIntIterable
- Specified by:
iterator
in interfaceIntSet
- Specified by:
iterator
in interfaceIterable<Integer>
- Specified by:
iterator
in interfaceSet<Integer>
-
intIterator
default IEdgeIter intIterator()
Return an edge iterator that iterate over the edges in this set.- Specified by:
intIterator
in interfaceIntCollection
- Specified by:
intIterator
in interfaceIntIterable
-
of
static IEdgeSet of(IntSet edges, IntGraph g)
Create an edge set object from a plain set of edges.A 'plain' set of edges is a set of the edges identifiers. It does not include any information about the endpoints (source and target) of each edge. This method creates an
IEdgeSet
, which does contains information about the endpoints, given a plain set of edges and the graph in which the edges are defined in.The returned set is a view of the given set and graph. Namely, its updated when the original set is updated and visa vera, and the endpoints in the
IEdgeSet
will be up to date with the given graph.No validation is performed to ensure that all the given edges are actually in the given graph. If this is not the case, an exception may be thrown later when the graph is queried for an edge source and target.
Usually an
IEdgeSet
object is obtained via one of the method of aIntGraph
, and rarely a user need to a create one, but it may be used to add multiple edges to a graph using theIntGraph.addEdges(EdgeSet)
method. In the following snippet, a maximum cardinality matching is computed on a graph, and a new graph containing only the matching edges is created:IntGraph g = ...; IntSet matching = (IntSet) MatchingAlgo.newInstance().computeMaximumMatching(g, null).edges(); IntGraph matchingGraph = IntGraph.newUndirected(); matchingGraph.addVertices(g.vertices()); matchingGraph.addEdges(IEdgeSet.of(matching, g));
- Parameters:
edges
- a set of edges identifiersg
- the graph in which the edges are defined in, and from which the endpoints of the edges should be retrieved- Returns:
- an
IEdgeSet
with the given edges, containing the endpoints information from the graph
-
allOf
static IEdgeSet allOf(IntGraph g)
Create an edge set object of all the edges in a graph.The edge set returned by
IntGraph.edges()
is a 'plain' set of edges, namely it is a set of the edge identifiers themselves but does not include any information about the endpoints (source and target) of each edge. This method creates anIEdgeSet
, which does contains information about the endpoints, of all the edges in a given graph.The returned set is a view of the given set and graph. Namely, its updated when the original set is updated and visa vera, and the endpoints in the
IEdgeSet
will be up to date with the given graph.Usually an
IEdgeSet
object is obtained via one of the method of aIntGraph
, and rarely a user need to a create one, but it may be used to add multiple edges to a graph using theIntGraph.addEdges(EdgeSet)
method. In the following snippet, an auxillary graph is created which is a copy of an original graphg
with additional vertex connected to all the original vertices, for shortest path potential function computation (used in Johnson APSP):int auxillaryVertex = ...; IntGraph auxillaryGraph = IntGraph.newDirected(); auxillaryGraph.addVertices(g.vertices()); auxillaryGraph.addVertex(auxillaryVertex); auxillaryGraph.addEdges(IEdgeSet.allOf(g)); for (int v : g.vertices()) auxillaryGraph.addEdge(auxillaryVertex, v);
- Parameters:
g
- a graph- Returns:
- an
IEdgeSet
of all the edges in the graph
-
-