V
- the graph vertex typeE
- the graph edge typepublic class DirectedSpecifics<V,E> extends Object implements Specifics<V,E>, Serializable
FastLookupDirectedSpecifics
.Modifier and Type | Field and Description |
---|---|
protected EdgeSetFactory<V,E> |
edgeSetFactory |
protected Graph<V,E> |
graph |
protected Map<V,DirectedEdgeContainer<V,E>> |
vertexMap |
Constructor and Description |
---|
DirectedSpecifics(Graph<V,E> graph,
Map<V,DirectedEdgeContainer<V,E>> vertexMap,
EdgeSetFactory<V,E> edgeSetFactory)
Construct a new directed specifics.
|
Modifier and Type | Method and Description |
---|---|
void |
addEdgeToTouchingVertices(E e)
Deprecated.
|
boolean |
addEdgeToTouchingVertices(V sourceVertex,
V targetVertex,
E e)
Adds the specified edge to the edge containers of its source and target vertices.
|
boolean |
addEdgeToTouchingVerticesIfAbsent(V sourceVertex,
V targetVertex,
E e)
Adds the specified edge to the edge containers of its source and target vertices only if the
edge is not already in the graph.
|
boolean |
addVertex(V v)
Adds a vertex.
|
E |
createEdgeToTouchingVerticesIfAbsent(V sourceVertex,
V targetVertex,
Supplier<E> edgeSupplier)
Creates an edge given an edge supplier and adds it to the edge containers of its source and
target vertices only if the graph does not contain other edges with the same source and
target vertices.
|
int |
degreeOf(V vertex)
Returns the degree of the specified vertex.
|
Set<E> |
edgesOf(V vertex)
Returns a set of all edges touching the specified vertex.
|
Set<E> |
getAllEdges(V sourceVertex,
V targetVertex)
Returns a set of all edges connecting source vertex to target vertex if such vertices exist
in this graph.
|
E |
getEdge(V sourceVertex,
V targetVertex)
Returns an edge connecting source vertex to target vertex if such vertices and such edge
exist in this graph.
|
protected DirectedEdgeContainer<V,E> |
getEdgeContainer(V vertex)
Get the edge container for specified vertex.
|
Set<V> |
getVertexSet()
Get the vertex set.
|
Set<E> |
incomingEdgesOf(V vertex)
Returns a set of all edges incoming into the specified vertex.
|
int |
inDegreeOf(V vertex)
Returns the "in degree" of the specified vertex.
|
int |
outDegreeOf(V vertex)
Returns the "out degree" of the specified vertex.
|
Set<E> |
outgoingEdgesOf(V vertex)
Returns a set of all edges outgoing from the specified vertex.
|
void |
removeEdgeFromTouchingVertices(E e)
Deprecated.
Use method
removeEdgeFromTouchingVertices(Object, Object, Object)
instead. |
void |
removeEdgeFromTouchingVertices(V sourceVertex,
V targetVertex,
E e)
Removes the specified edge from the edge containers of its source and target vertices.
|
protected Map<V,DirectedEdgeContainer<V,E>> vertexMap
protected EdgeSetFactory<V,E> edgeSetFactory
public DirectedSpecifics(Graph<V,E> graph, Map<V,DirectedEdgeContainer<V,E>> vertexMap, EdgeSetFactory<V,E> edgeSetFactory)
graph
- the graph for which these specifics are forvertexMap
- map for the storage of vertex edge sets. Needs to have a predictable
iteration order.edgeSetFactory
- factory for the creation of vertex edge setspublic boolean addVertex(V v)
public Set<V> getVertexSet()
getVertexSet
in interface Specifics<V,E>
public Set<E> getAllEdges(V sourceVertex, V targetVertex)
null
, returns
null
. If both vertices exist but no edges found, returns an empty set.getAllEdges
in interface Specifics<V,E>
sourceVertex
- source vertex of the edge.targetVertex
- target vertex of the edge.public E getEdge(V sourceVertex, V targetVertex)
null
. If any of the specified vertices is null
returns null
In undirected graphs, the returned edge may have its source and target vertices in the opposite order.
@Deprecated public void addEdgeToTouchingVertices(E e)
Specifics
addEdgeToTouchingVertices
in interface Specifics<V,E>
e
- the edgepublic boolean addEdgeToTouchingVertices(V sourceVertex, V targetVertex, E e)
addEdgeToTouchingVertices
in interface Specifics<V,E>
sourceVertex
- the source vertextargetVertex
- the target vertexe
- the edgepublic boolean addEdgeToTouchingVerticesIfAbsent(V sourceVertex, V targetVertex, E e)
Specifics
addEdgeToTouchingVerticesIfAbsent
in interface Specifics<V,E>
sourceVertex
- the source vertextargetVertex
- the target vertexe
- the edgepublic E createEdgeToTouchingVerticesIfAbsent(V sourceVertex, V targetVertex, Supplier<E> edgeSupplier)
Specifics
createEdgeToTouchingVerticesIfAbsent
in interface Specifics<V,E>
sourceVertex
- the source vertextargetVertex
- the target vertexedgeSupplier
- the function which will create the edgepublic int degreeOf(V vertex)
public Set<E> edgesOf(V vertex)
public int inDegreeOf(V vertex)
inDegreeOf
in interface Specifics<V,E>
vertex
- vertex whose in degree is to be calculated.public Set<E> incomingEdgesOf(V vertex)
incomingEdgesOf
in interface Specifics<V,E>
vertex
- the vertex for which the list of incoming edges to be returned.public int outDegreeOf(V vertex)
outDegreeOf
in interface Specifics<V,E>
vertex
- vertex whose out degree is to be calculated.public Set<E> outgoingEdgesOf(V vertex)
outgoingEdgesOf
in interface Specifics<V,E>
vertex
- the vertex for which the list of outgoing edges to be returned.@Deprecated public void removeEdgeFromTouchingVertices(E e)
removeEdgeFromTouchingVertices(Object, Object, Object)
instead.removeEdgeFromTouchingVertices
in interface Specifics<V,E>
e
- the edgepublic void removeEdgeFromTouchingVertices(V sourceVertex, V targetVertex, E e)
removeEdgeFromTouchingVertices
in interface Specifics<V,E>
sourceVertex
- the source vertextargetVertex
- the target vertexe
- the edgeprotected DirectedEdgeContainer<V,E> getEdgeContainer(V vertex)
vertex
- a vertex in this graph.Copyright © 2019. All rights reserved.