Class IncomingNoReindexSparseDirectedSpecifics
- java.lang.Object
-
- org.jgrapht.opt.graph.sparse.specifics.NoIncomingNoReindexSparseDirectedSpecifics
-
- org.jgrapht.opt.graph.sparse.specifics.IncomingNoReindexSparseDirectedSpecifics
-
- All Implemented Interfaces:
SparseGraphSpecifics
public class IncomingNoReindexSparseDirectedSpecifics extends NoIncomingNoReindexSparseDirectedSpecifics
Specifics for a sparse directed graph which does not re-index the edges and supports incoming edges. No reindexing means that the edges are numbered in increasing order using the order that the user loads the edges. Support for incoming edges is provided but is initialized lazily the first time the user accessed a corresponding method.
-
-
Field Summary
Fields Modifier and Type Field Description protected CSRBooleanMatrix
inIncidenceMatrix
Incidence matrix with incoming edges-
Fields inherited from class org.jgrapht.opt.graph.sparse.specifics.NoIncomingNoReindexSparseDirectedSpecifics
NO_INCOMING, outIncidenceMatrix, source, target, UNMODIFIABLE
-
-
Constructor Summary
Constructors Constructor Description IncomingNoReindexSparseDirectedSpecifics(int numVertices, int numEdges, java.util.function.Supplier<java.util.stream.Stream<Pair<java.lang.Integer,java.lang.Integer>>> edges, boolean lazyIncomingEdges)
Create a new graph from an edge list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
degreeOf(java.lang.Integer vertex)
Returns the degree of the specified vertex.java.util.Set<java.lang.Integer>
edgesOf(java.lang.Integer vertex)
Returns a set of all edges touching the specified vertex.java.util.Set<java.lang.Integer>
incomingEdgesOf(java.lang.Integer vertex)
Returns a set of all edges incoming into the specified vertex.long
inDegreeOf(java.lang.Integer vertex)
Returns the "in degree" of the specified vertex.protected void
indexIncomingEdges()
Build the index for the incoming edges.-
Methods inherited from class org.jgrapht.opt.graph.sparse.specifics.NoIncomingNoReindexSparseDirectedSpecifics
edgesCount, getAllEdges, getEdge, getEdgeSource, getEdgeTarget, getType, outDegreeOf, outgoingEdgesOf, verticesCount
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jgrapht.opt.graph.sparse.specifics.SparseGraphSpecifics
assertEdgeExist, assertVertexExist, containsEdge, containsVertex, edgeSet, getEdgeWeight, setEdgeWeight, vertexSet
-
-
-
-
Field Detail
-
inIncidenceMatrix
protected CSRBooleanMatrix inIncidenceMatrix
Incidence matrix with incoming edges
-
-
Constructor Detail
-
IncomingNoReindexSparseDirectedSpecifics
public IncomingNoReindexSparseDirectedSpecifics(int numVertices, int numEdges, java.util.function.Supplier<java.util.stream.Stream<Pair<java.lang.Integer,java.lang.Integer>>> edges, boolean lazyIncomingEdges)
Create a new graph from an edge list.- Parameters:
numVertices
- the number of verticesnumEdges
- the number of edgesedges
- a supplier of an edge streamlazyIncomingEdges
- whether to lazily support incoming edge traversals, only if actually needed by the user
-
-
Method Detail
-
degreeOf
public long degreeOf(java.lang.Integer vertex)
Description copied from interface:SparseGraphSpecifics
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".
- Specified by:
degreeOf
in interfaceSparseGraphSpecifics
- Overrides:
degreeOf
in classNoIncomingNoReindexSparseDirectedSpecifics
- Parameters:
vertex
- vertex whose degree is to be calculated.- Returns:
- the degree of the specified vertex.
-
edgesOf
public java.util.Set<java.lang.Integer> edgesOf(java.lang.Integer vertex)
Description copied from interface:SparseGraphSpecifics
Returns a set of all edges touching the specified vertex. If no edges are touching the specified vertex returns an empty set.- Specified by:
edgesOf
in interfaceSparseGraphSpecifics
- Overrides:
edgesOf
in classNoIncomingNoReindexSparseDirectedSpecifics
- Parameters:
vertex
- the vertex for which a set of touching edges is to be returned.- Returns:
- a set of all edges touching the specified vertex.
-
inDegreeOf
public long inDegreeOf(java.lang.Integer vertex)
Description copied from interface:SparseGraphSpecifics
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 interfaceSparseGraphSpecifics
- Overrides:
inDegreeOf
in classNoIncomingNoReindexSparseDirectedSpecifics
- Parameters:
vertex
- vertex whose degree is to be calculated.- Returns:
- the degree of the specified vertex.
-
incomingEdgesOf
public java.util.Set<java.lang.Integer> incomingEdgesOf(java.lang.Integer vertex)
Description copied from interface:SparseGraphSpecifics
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 interfaceSparseGraphSpecifics
- Overrides:
incomingEdgesOf
in classNoIncomingNoReindexSparseDirectedSpecifics
- 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.
-
indexIncomingEdges
protected void indexIncomingEdges()
Build the index for the incoming edges.
-
-