Class IncidenceMatrixSparseUndirectedSpecifics
- All Implemented Interfaces:
SparseGraphSpecifics
- Author:
- Dimitrios Michail
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CSRBooleanMatrixprotected int[]protected int[]protected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the degree of the specified vertex.longGet the number of edges.Returns a set of all edges touching the specified vertex.getAllEdges(Integer sourceVertex, Integer targetVertex) Returns a set of all edges connecting source vertex to target vertex if such vertices exist in this graph.Returns an edge connecting source vertex to target vertex if such vertices and such edge exist in this graph.Returns the source vertex of an edge.Returns the target vertex of an edge.getType()Get the graph type.incomingEdgesOf(Integer vertex) Returns a set of all edges incoming into the specified vertex.longinDegreeOf(Integer vertex) Returns the "in degree" of the specified vertex.longoutDegreeOf(Integer vertex) Returns the "out degree" of the specified vertex.outgoingEdgesOf(Integer vertex) Returns a set of all edges outgoing from the specified vertex.longGet the number of verticesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jgrapht.opt.graph.sparse.specifics.SparseGraphSpecifics
assertEdgeExist, assertVertexExist, containsEdge, containsVertex, edgeSet, getEdgeWeight, setEdgeWeight, vertexSet
-
Field Details
-
UNMODIFIABLE
- See Also:
-
incidenceMatrix
-
source
protected int[] source -
target
protected int[] target
-
-
Constructor Details
-
IncidenceMatrixSparseUndirectedSpecifics
public IncidenceMatrixSparseUndirectedSpecifics(int numVertices, int numEdges, Supplier<Stream<Pair<Integer, Integer>>> edges) Create a new graph from an edge stream- Parameters:
numVertices- number of verticesnumEdges- number of edgesedges- a supplier of an edge stream
-
-
Method Details
-
edgesCount
public long edgesCount()Description copied from interface:SparseGraphSpecificsGet the number of edges.- Specified by:
edgesCountin interfaceSparseGraphSpecifics- Returns:
- the number of edges
-
verticesCount
public long verticesCount()Description copied from interface:SparseGraphSpecificsGet the number of vertices- Specified by:
verticesCountin interfaceSparseGraphSpecifics- Returns:
- the number of vertices
-
degreeOf
Description copied from interface:SparseGraphSpecificsReturns 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:
degreeOfin interfaceSparseGraphSpecifics- Parameters:
vertex- vertex whose degree is to be calculated.- Returns:
- the degree of the specified vertex.
-
edgesOf
Description copied from interface:SparseGraphSpecificsReturns a set of all edges touching the specified vertex. If no edges are touching the specified vertex returns an empty set.- Specified by:
edgesOfin interfaceSparseGraphSpecifics- 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
Description copied from interface:SparseGraphSpecificsReturns 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 interfaceSparseGraphSpecifics- Parameters:
vertex- vertex whose degree is to be calculated.- Returns:
- the degree of the specified vertex.
-
incomingEdgesOf
Description copied from interface:SparseGraphSpecificsReturns 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 interfaceSparseGraphSpecifics- 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:SparseGraphSpecificsReturns 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 interfaceSparseGraphSpecifics- Parameters:
vertex- vertex whose degree is to be calculated.- Returns:
- the degree of the specified vertex.
-
outgoingEdgesOf
Description copied from interface:SparseGraphSpecificsReturns 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 interfaceSparseGraphSpecifics- 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.
-
getType
Description copied from interface:SparseGraphSpecificsGet 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.- Specified by:
getTypein interfaceSparseGraphSpecifics- Returns:
- the graph type
-
getEdgeSource
Description copied from interface:SparseGraphSpecificsReturns the source vertex of an edge. For an undirected graph, source and target are distinguishable designations (but without any mathematical meaning).- Specified by:
getEdgeSourcein interfaceSparseGraphSpecifics- Parameters:
e- edge of interest- Returns:
- source vertex
-
getEdgeTarget
Description copied from interface:SparseGraphSpecificsReturns the target vertex of an edge. For an undirected graph, source and target are distinguishable designations (but without any mathematical meaning).- Specified by:
getEdgeTargetin interfaceSparseGraphSpecifics- Parameters:
e- edge of interest- Returns:
- target vertex
-
getEdge
Returns an edge connecting source vertex to target vertex if such vertices and such edge exist in this graph. Otherwise returnsnull. If any of the specified vertices isnullreturnsnullIn undirected graphs, the returned edge may have its source and target vertices in the opposite order.
This operation costs $O(d)$ where $d$ is the degree of the source vertex.- Specified by:
getEdgein interfaceSparseGraphSpecifics- Parameters:
sourceVertex- source vertex of the edge.targetVertex- target vertex of the edge.- Returns:
- an edge connecting source vertex to target vertex.
-
getAllEdges
Returns a set of all edges connecting source vertex to target vertex if such vertices exist in this graph. If any of the vertices does not exist or isnull, returnsnull. If both vertices exist but no edges found, returns an empty set.In undirected graphs, some of the returned edges may have their source and target vertices in the opposite order. In simple graphs the returned set is either singleton set or empty set.
This operation costs $O(d)$ where $d$ is the degree of the source vertex.- Specified by:
getAllEdgesin interfaceSparseGraphSpecifics- Parameters:
sourceVertex- source vertex of the edge.targetVertex- target vertex of the edge.- Returns:
- a set of all edges connecting source vertex to target vertex.
-