- Type Parameters:
ID
- type of all identifiers in graph
- All Known Subinterfaces:
EventPropertyGraph<ID>
- All Known Implementing Classes:
AbstractPropertyGraph
,DirectedPropertyGraph
,UndirectedPropertyGraph
public interface PropertyGraph<ID>
A graph is composed of vertices and edges. A vertex is able to connect to other vertices through edges. Edges
connect two vertices. A graph can be directed or undirected.
Vertices have an id which uniquely identifies the vertex within the graph. Edges have a source and target property which are the ids of the vertex endpoints. Edges are optionally identified.
At all times the graph is valid event when removing connected vertices.
Undirected graphs ignore source/target order in edges.
Once a vertex or edge is removed it can no longer modify the graph or be modified.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
An edge between two vertices in a graph.static interface
Vertex of graph. -
Method Summary
Modifier and TypeMethodDescriptiondefault Iterator<PropertyGraph.Vertex<ID>>
breadthFirstIterator
(ID... start) Returns a breadth-firstIterator
of everyPropertyGraph.Vertex
in this graph starting at the provided vertices.default Stream<PropertyGraph.Vertex<ID>>
breadthFirstStream
(ID... start) Returns a breadth-firstStream
of everyPropertyGraph.Vertex
in this graph starting at the provided vertices.default boolean
Returns true if source and target vertices are connected.Ensures an edge exists between source and target vertices.edge
(ID source, ID target, String name1, Object value1, String name2, Object value2, String name3, Object value3) edge
(ID source, ID target, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4) edge
(ID source, ID target, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5) edge
(ID source, ID target, 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 source, ID target, 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 source, ID target, 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 source, ID target, 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 source, ID target, 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) finds edge with given id.Finds edge connecting source and target 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 source, ID target, String name1, Object value1, String name2, Object value2, String name3, Object value3) getEdge
(ID source, ID target, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4) getEdge
(ID source, ID target, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5) getEdge
(ID source, ID target, 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 source, ID target, 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 source, ID target, 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 source, ID target, 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 source, ID target, 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) 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.Returns an ordered map of all vertices in this graph.Sets the id of this graphboolean
Returns true if this graph is directed.default boolean
isEmpty()
Returns true if this graph is empty.default Iterator<PropertyGraph.Vertex<ID>>
postOrderIterator
(ID... start) Returns a post-order depth-firstIterator
which returns everyPropertyGraph.Vertex
in this graph starting at the provided vertices.default Stream<PropertyGraph.Vertex<ID>>
postOrderStream
(ID... start) Returns a post-order depth-firstStream
of everyPropertyGraph.Vertex
in this graph starting at the provided vertices.default Iterator<PropertyGraph.Vertex<ID>>
preOrderIterator
(ID... start) Returns a pre-order depth-firstIterator
of everyPropertyGraph.Vertex
in this graph starting at the provided vertices.default Stream<PropertyGraph.Vertex<ID>>
preOrderStream
(ID... start) Returns a pre-order depth-firstStream
of everyPropertyGraph.Vertex
in this graph starting at the provided vertices.Sets property on this graph returning this graphvoid
removeEdge
(ID id) Removes edge with given idvoid
removeEdge
(ID source, ID target) 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)
-
Method Details
-
getVertices
Map<ID,PropertyGraph.Vertex<ID>> getVertices()Returns an ordered map of all vertices in this graph. The key is the vertex id. Ordering is determined by implementing class.- Returns:
- ordered map of all vertices in this graph
-
getEdges
Collection<PropertyGraph.Edge<ID>> getEdges()Returns an ordered collection of all edges in this graph.- Returns:
- ordered collection of all edges
-
getEdgeIds
Map<ID,PropertyGraph.Edge<ID>> getEdgeIds()Returns a map of edge ids to edges.- Returns:
- map of edge ids to edges
-
findVertex
Finds vertex with given id. If vertex is not in this graph the optional is empty.- Parameters:
id
- of vertex- Returns:
- optional of vertex
- Throws:
NullPointerException
- if id is null
-
vertex
Ensure a vertex exists with id and returns the vertex. If the vertex does not exist it is created.- Parameters:
id
- of vertex- Returns:
- created or existing vertex
- Throws:
NullPointerException
- if id is null
-
vertex
-
vertex
-
vertex
-
vertex
-
vertex
-
vertex
-
vertex
-
vertex
-
vertex
-
vertex
PropertyGraph<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
PropertyGraph.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
PropertyGraph.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
-
removeVertex
Removes vertex with given id. If edges connect to the vertex they are removed first.- Parameters:
id
- of vertex- Throws:
NullPointerException
- if id is null
-
findEdge
Finds edge connecting source and target vertex. If edge is not in this graph the optional is empty. The order of source and target does not matter in undirected implementations. However, if the graph is directed source and target must match source and target of the edge exactly.- Parameters:
source
- of edgetarget
- of edge- Returns:
- optional of edge
- Throws:
NullPointerException
- if source or target is null
-
findEdge
finds edge with given id. If edge is not in this graph the optional is empty.- Parameters:
id
- of edge- Returns:
- optional of edge
- Throws:
NullPointerException
- if id is null
-
edge
Ensures an edge exists between source and target 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 source and target the edge will not be created. Undirected graphs ignore source/target order in edges.
- Parameters:
source
- of edgetarget
- of edge- Returns:
- created or existing edge
-
edge
-
edge
-
edge
-
edge
-
edge
-
edge
-
edge
-
edge
-
edge
PropertyGraph<ID> edge(ID source, ID target, 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
PropertyGraph<ID> edge(ID source, ID target, 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
PropertyGraph.Edge<ID> getEdge(ID source, ID target, 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
PropertyGraph.Edge<ID> getEdge(ID source, ID target, 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
-
removeEdge
Removes edge with given from and to.- Parameters:
source
- of edgetarget
- of edge- Throws:
NullPointerException
- if source or target is nullIllegalArgumentException
- if edge does not exist
-
removeEdge
Removes edge with given id- Parameters:
id
- of edge- Throws:
NullPointerException
- if id is nullIllegalArgumentException
- if edge with id does not exist
-
getId
Returns the id of this graph. If the id is not set and empty optional is returned.- Returns:
- optional of id
-
setId
Sets the id of this graph.- Parameters:
id
- of graph- Throws:
NullPointerException
- if id is null
-
id
Sets the id of this graph- Parameters:
id
- of graph- Returns:
- this graph
- Throws:
NullPointerException
- if id is null
-
isDirected
boolean isDirected()Returns true if this graph is directed.- Returns:
- if this graph is directed
-
getProperties
Returns an unmodifiable map of properties for this graph.- Returns:
- an unmodifiable map of properties for this graph
-
findProperty
- Parameters:
name
- of property- Returns:
- optional of named proeprty
- Throws:
NullPointerException
- if name is null
-
getProperty
Returns a property. If the property does not exist null is returned.- Type Parameters:
T
- return type of property- Parameters:
name
- of property- Returns:
- value of named property
- Throws:
NullPointerException
- if name is null
-
setProperty
Sets property on this graph- Parameters:
name
- of propertyvalue
- of property- Throws:
NullPointerException
- if name or value is null
-
property
Sets property on this graph returning this graph- Parameters:
name
- of propertyvalue
- of property- Returns:
- this graph
- Throws:
NullPointerException
- if name or value is null
-
property
-
removeProperty
Removes property on this graph returning this graph- Parameters:
name
- of property- Returns:
- this graph
- Throws:
NullPointerException
- if name is null
-
getEdgeProperties
Returns an unmodifiable map of edge properties.- Returns:
- an unmodifiable map of edge properties
-
findEdgeProperty
ReturnsOptional
of an edge property. If the property does not exist the returnedOptional
is empty.- Parameters:
name
- of property- Returns:
- optional of property
- Throws:
NullPointerException
- if name is null
-
getEdgeProperty
Returns an edge property. If the property does not exist null is returned.- Parameters:
name
- of property- Returns:
- property value
- Throws:
NullPointerException
- if name is null
-
setEdgeProperty
Sets edge property.- Parameters:
name
- of propertyvalue
- of property- Throws:
NullPointerException
- if name or value is null
-
edgeProperty
Sets edge property returning this graph- Parameters:
name
- of edge propertyvalue
- of edge property- Returns:
- this graph
- Throws:
NullPointerException
- if name or value is null
-
edgeProperty
-
removeEdgeProperty
Removes edge property returning this graph- Parameters:
name
- of property- Returns:
- this graph
- Throws:
NullPointerException
- if name is null
-
getVertexProperties
Retruns an unmodifiable map of vertex properties.- Returns:
- an unmodifiable map of vertex properties
-
findVertexProperty
ReturnsOptional
of a vertex property. If the property does not exist the returnedOptional
is empty.- Parameters:
name
- of property- Returns:
- optional of property
- Throws:
NullPointerException
- if name is null
-
getVertexProperty
Returns a vertex property. If the property does not exist null is returned.- Parameters:
name
- of property- Returns:
- property value
- Throws:
NullPointerException
- if name is null
-
setVertexProperty
Sets vertex property.- Parameters:
name
- of propertyvalue
- of property- Throws:
NullPointerException
- if name or value is null
-
vertexProperty
Sets vertex property returning this graph- Parameters:
name
- of propertyvalue
- of property- Returns:
- created or existing edge
- Throws:
NullPointerException
- if name or value is null
-
vertexProperty
-
removeVertexProperty
Removes vertex property returning this graph- Parameters:
name
- of property- Returns:
- this graph
- Throws:
NullPointerException
- if name is null
-
connected
Returns true if source and target vertices are connected.- Parameters:
source
- id of vertextarget
- id of vertex- Returns:
- true if the two vertices are connected
-
postOrderIterator
Returns a post-order depth-firstIterator
which returns everyPropertyGraph.Vertex
in this graph starting at the provided vertices.- Parameters:
start
- ids of traversal- Returns:
- Throws:
NullPointerException
- if start is null or any id in startIllegalArgumentException
- if start contains ids that are not in the graph
-
postOrderStream
Returns a post-order depth-firstStream
of everyPropertyGraph.Vertex
in this graph starting at the provided vertices.- Parameters:
start
- ids of traversal- Returns:
- Throws:
NullPointerException
- if start is null or any id in startIllegalArgumentException
- if start contains ids that are not in the graph
-
preOrderIterator
Returns a pre-order depth-firstIterator
of everyPropertyGraph.Vertex
in this graph starting at the provided vertices.- Parameters:
start
- ids of traversal- Returns:
- Throws:
NullPointerException
- if start is null or any id in startIllegalArgumentException
- if start contains ids that are not in the graph
-
preOrderStream
Returns a pre-order depth-firstStream
of everyPropertyGraph.Vertex
in this graph starting at the provided vertices.- Parameters:
start
- ids of traversal- Returns:
- Throws:
NullPointerException
- if start is null or any id in startIllegalArgumentException
- if start contains ids that are not in the graph
-
breadthFirstIterator
Returns a breadth-firstIterator
of everyPropertyGraph.Vertex
in this graph starting at the provided vertices.- Parameters:
start
- ids of traversal- Returns:
- Throws:
NullPointerException
- if start is null or any id in startIllegalArgumentException
- if start contains ids that are not in the graph
-
breadthFirstStream
Returns a breadth-firstStream
of everyPropertyGraph.Vertex
in this graph starting at the provided vertices.- Parameters:
start
- ids of traversal- Returns:
- Throws:
NullPointerException
- if start is null or any id in startIllegalArgumentException
- if start contains ids that are not in the graph
-
isEmpty
default boolean isEmpty()Returns true if this graph is empty.- Returns:
-