java.lang.Object
com.github.moaxcp.graphs.AbstractGraph<ID>
- Type Parameters:
ID
- type of all identifiers in graph
- All Implemented Interfaces:
Graph<ID>
- Direct Known Subclasses:
DirectedGraph
,UndirectedGraph
This class provides a partial implementation of the
Graph
interface.
Vertices and edges are stored in insertion order.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.github.moaxcp.graphs.Graph
Graph.Edge<ID>, Graph.Vertex<ID>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Graph.Edge<ID>
protected Graph.Vertex<ID>
Ensures an edge exists between 'from' and 'to' vertices.edge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3) edge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4) edge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5) edge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6) edge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7) edge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8) edge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9) edge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9, String name10, Object value10) edgeProperty
(String name, Object value) Sets edge property returning this graphedgeProperty
(Map<String, Object> properties) final boolean
finds edge with given id.Finds edge connecting 'from' and 'to' vertex.<T> Optional<T>
findEdgeProperty
(String name) ReturnsOptional
of an edge property.<T> Optional<T>
findProperty
(String name) ReturnsOptional
of a property.findVertex
(ID id) Finds vertex with given id.<T> Optional<T>
findVertexProperty
(String name) ReturnsOptional
of a vertex property.getEdge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3) getEdge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4) getEdge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5) getEdge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6) getEdge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7) getEdge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8) getEdge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9) getEdge
(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9, String name10, Object value10) Map<ID,
Graph.Edge<ID>> Returns a map of edge ids to edges.Returns an unmodifiable map of edge properties.<T> T
getEdgeProperty
(String name) Returns an edge property.getEdges()
Returns an ordered collection of all edges in this graph.getId()
Returns the id of this graph.Returns an unmodifiable map of properties for this graph.<T> T
getProperty
(String name) Returns a property.getVertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3) getVertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4) getVertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5) getVertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6) getVertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7) getVertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8) getVertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9) getVertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9, String name10, Object value10) Retruns an unmodifiable map of vertex properties.<T> T
getVertexProperty
(String name) Returns a vertex property.Map<ID,
Graph.Vertex<ID>> Returns an ordered map of all vertices in this graph.final int
hashCode()
Sets the id of this graphprotected Graph.Edge<ID>
newEdgeKey
(ID from, ID to) protected Graph.Vertex<ID>
Sets property on this graph returning this graphvoid
removeEdge
(ID id) Removes edge with given idvoid
removeEdge
(ID from, ID to) Removes edge with given from and to.removeEdgeProperty
(String name) Removes edge property returning this graphremoveProperty
(String name) Removes property on this graph returning this graphvoid
removeVertex
(ID id) Removes vertex with given id.removeVertexProperty
(String name) Removes vertex property returning this graphvoid
setEdgeProperty
(String name, Object value) Sets edge property.void
Sets the id of this graph.void
setProperty
(String name, Object value) Sets property on this graphvoid
setVertexProperty
(String name, Object value) Sets vertex property.Ensure a vertex exists with id and returns the vertex.vertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3) vertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4) vertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5) vertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6) vertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7) vertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8) vertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9) vertex
(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9, String name10, Object value10) vertexProperty
(String name, Object value) Sets vertex property returning this graphvertexProperty
(Map<String, Object> properties) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.github.moaxcp.graphs.Graph
breadthFirstIterator, breadthFirstStream, connected, isDirected, isEmpty, postOrderIterator, postOrderStream, preOrderIterator, preOrderStream
-
Constructor Details
-
AbstractGraph
protected AbstractGraph() -
AbstractGraph
-
-
Method Details
-
getVertices
Description copied from interface:Graph
Returns an ordered map of all vertices in this graph. The key is the vertex id. Ordering is determined by implementing class.- Specified by:
getVertices
in interfaceGraph<ID>
- Returns:
- ordered map of all vertices in this graph
-
getEdges
Description copied from interface:Graph
Returns an ordered collection of all edges in this graph. -
getEdgeIds
Description copied from interface:Graph
Returns a map of edge ids to edges.- Specified by:
getEdgeIds
in interfaceGraph<ID>
- Returns:
- map of edge ids to edges
-
findVertex
Description copied from interface:Graph
Finds vertex with given id. If vertex is not in this graph the optional is empty.- Specified by:
findVertex
in interfaceGraph<ID>
- Parameters:
id
- of vertex- Returns:
- optional of vertex
-
vertex
Description copied from interface:Graph
Ensure a vertex exists with id and returns the vertex. If the vertex does not exist it is created. -
vertex
-
vertex
-
vertex
-
vertex
-
vertex
-
vertex
-
vertex
-
vertex
-
vertex
-
vertex
public Graph<ID> vertex(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9, String name10, Object value10) -
vertex
-
getVertex
-
getVertex
-
getVertex
-
getVertex
-
getVertex
-
getVertex
-
getVertex
-
getVertex
-
getVertex
-
getVertex
public Graph.Vertex<ID> getVertex(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9) -
getVertex
public Graph.Vertex<ID> getVertex(ID id, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9, String name10, Object value10) -
getVertex
-
addVertex
-
removeVertex
Description copied from interface:Graph
Removes vertex with given id. If edges connect to the vertex they are removed first.- Specified by:
removeVertex
in interfaceGraph<ID>
- Parameters:
id
- of vertex
-
findEdge
Description copied from interface:Graph
Finds edge connecting 'from' and 'to' vertex. If edge is not in this graph the optional is empty. The order of 'from' and 'to' does not matter in undirected implementations. However, if the graph is directed 'from' and 'to' must match 'from' and 'to' of the edge exactly. -
findEdge
Description copied from interface:Graph
finds edge with given id. If edge is not in this graph the optional is empty. -
edge
Description copied from interface:Graph
Ensures an edge exists between 'from' and 'to' vertices. If an edge does not exist it is created. If any of the vertices do not exist they are created.If this graph is undirected and contains an edge connecting 'to' and 'from' the edge will not be created. Undirected graphs ignore 'from'/'to' order in edges.
-
edge
-
edge
-
edge
-
edge
-
edge
-
edge
-
edge
-
edge
-
edge
-
edge
public Graph<ID> edge(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9, String name10, Object value10) -
edge
-
getEdge
-
getEdge
-
getEdge
-
getEdge
-
getEdge
-
getEdge
-
getEdge
-
getEdge
-
getEdge
-
getEdge
public Graph.Edge<ID> getEdge(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9) -
getEdge
public Graph.Edge<ID> getEdge(ID from, ID to, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9, String name10, Object value10) -
getEdge
-
newEdge
-
newEdgeKey
-
newVertex
-
addEdge
-
removeEdge
Description copied from interface:Graph
Removes edge with given from and to.- Specified by:
removeEdge
in interfaceGraph<ID>
- Parameters:
from
- of edgeto
- of edge
-
removeEdge
Description copied from interface:Graph
Removes edge with given id- Specified by:
removeEdge
in interfaceGraph<ID>
- Parameters:
id
- of edge
-
getId
Description copied from interface:Graph
Returns the id of this graph. If the id is not set and empty optional is returned. -
setId
Description copied from interface:Graph
Sets the id of this graph. -
id
Description copied from interface:Graph
Sets the id of this graph -
getProperties
Description copied from interface:Graph
Returns an unmodifiable map of properties for this graph.- Specified by:
getProperties
in interfaceGraph<ID>
- Returns:
- an unmodifiable map of properties for this graph
-
findProperty
Description copied from interface:Graph
- Specified by:
findProperty
in interfaceGraph<ID>
- Parameters:
name
- of property- Returns:
- optional of named proeprty
-
getProperty
Description copied from interface:Graph
Returns a property. If the property does not exist null is returned.- Specified by:
getProperty
in interfaceGraph<ID>
- Type Parameters:
T
- return type of property- Parameters:
name
- of property- Returns:
- value of named property
-
setProperty
Description copied from interface:Graph
Sets property on this graph- Specified by:
setProperty
in interfaceGraph<ID>
- Parameters:
name
- of propertyvalue
- of property
-
property
Description copied from interface:Graph
Sets property on this graph returning this graph -
property
-
removeProperty
Description copied from interface:Graph
Removes property on this graph returning this graph- Specified by:
removeProperty
in interfaceGraph<ID>
- Parameters:
name
- of property- Returns:
- this graph
-
getEdgeProperties
Description copied from interface:Graph
Returns an unmodifiable map of edge properties.- Specified by:
getEdgeProperties
in interfaceGraph<ID>
- Returns:
- an unmodifiable map of edge properties
-
findEdgeProperty
Description copied from interface:Graph
ReturnsOptional
of an edge property. If the property does not exist the returnedOptional
is empty.- Specified by:
findEdgeProperty
in interfaceGraph<ID>
- Parameters:
name
- of property- Returns:
- optional of property
-
getEdgeProperty
Description copied from interface:Graph
Returns an edge property. If the property does not exist null is returned.- Specified by:
getEdgeProperty
in interfaceGraph<ID>
- Parameters:
name
- of property- Returns:
- property value
-
setEdgeProperty
Description copied from interface:Graph
Sets edge property.- Specified by:
setEdgeProperty
in interfaceGraph<ID>
- Parameters:
name
- of propertyvalue
- of property
-
edgeProperty
Description copied from interface:Graph
Sets edge property returning this graph- Specified by:
edgeProperty
in interfaceGraph<ID>
- Parameters:
name
- of edge propertyvalue
- of edge property- Returns:
- this graph
-
edgeProperty
- Specified by:
edgeProperty
in interfaceGraph<ID>
-
removeEdgeProperty
Description copied from interface:Graph
Removes edge property returning this graph- Specified by:
removeEdgeProperty
in interfaceGraph<ID>
- Parameters:
name
- of property- Returns:
- this graph
-
getVertexProperties
Description copied from interface:Graph
Retruns an unmodifiable map of vertex properties.- Specified by:
getVertexProperties
in interfaceGraph<ID>
- Returns:
- an unmodifiable map of vertex properties
-
findVertexProperty
Description copied from interface:Graph
ReturnsOptional
of a vertex property. If the property does not exist the returnedOptional
is empty.- Specified by:
findVertexProperty
in interfaceGraph<ID>
- Parameters:
name
- of property- Returns:
- optional of property
-
getVertexProperty
Description copied from interface:Graph
Returns a vertex property. If the property does not exist null is returned.- Specified by:
getVertexProperty
in interfaceGraph<ID>
- Parameters:
name
- of property- Returns:
- property value
-
setVertexProperty
Description copied from interface:Graph
Sets vertex property.- Specified by:
setVertexProperty
in interfaceGraph<ID>
- Parameters:
name
- of propertyvalue
- of property
-
vertexProperty
Description copied from interface:Graph
Sets vertex property returning this graph- Specified by:
vertexProperty
in interfaceGraph<ID>
- Parameters:
name
- of propertyvalue
- of property- Returns:
- created or existing edge
-
vertexProperty
- Specified by:
vertexProperty
in interfaceGraph<ID>
-
removeVertexProperty
Description copied from interface:Graph
Removes vertex property returning this graph- Specified by:
removeVertexProperty
in interfaceGraph<ID>
- Parameters:
name
- of property- Returns:
- this graph
-
equals
-
hashCode
public final int hashCode()
-