V
- The node implementation.public abstract class DirectedGraph<V extends Node<V>> extends Object implements Graph<V>
Modifier and Type | Field and Description |
---|---|
protected TreeMap<String,Edge<V>> |
edges |
protected TreeMap<String,V> |
nodes |
Constructor and Description |
---|
DirectedGraph() |
Modifier and Type | Method and Description |
---|---|
Edge<V> |
addEdge(RelationType type,
String id,
String label,
V sourceNode,
V destinationNode)
Creates a new edge instance with the given id or returns the edge instance with the given id and
type.
|
Edge<V> |
addEdge(String id,
String label,
V sourceNode,
V destinationNode)
Creates a new edge instance with the given id or returns the edge instance with the given id.
|
V |
addNode(String id,
String label)
Adds a new node if the id does not exist yet, otherwise returns the node with the given id
and the new label set.
|
protected Edge<V> |
createNewEdge(RelationType type,
V sourceNode,
V destinationNode)
Creates a new edge instance on each method call.
|
protected V |
createNewNode() |
List<V> |
findNodes(String query)
Finds nodes using a given query.
|
Edge<V> |
getEdge(String id)
Returns the edge with the given id.
|
V |
getNode(String id)
Returns the node with the given id
|
Set<V> |
getNodes()
Returns all nodes of the graph
|
Edge<V> |
newEdge(RelationType type,
String label,
V sourceNode,
V destinationNode)
Creates a new edge instance with the given label.
|
Edge<V> |
newEdge(String label,
V sourceNode,
V destinationNode)
Creates a new edge instance with the given label.
|
V |
newNode(String label)
Creates a node with the given label in the graph.
|
void |
removeEdge(Edge<V> edge)
Removes the edge from the graph and unregisters it from the source and destination
|
void |
removeNode(V node) |
public DirectedGraph()
public V newNode(String label)
Graph
public V addNode(String id, String label)
Graph
protected V createNewNode()
protected Edge<V> createNewEdge(RelationType type, V sourceNode, V destinationNode)
type
- the relation typesourceNode
- the source nodedestinationNode
- the destination nodepublic Edge<V> newEdge(String label, V sourceNode, V destinationNode)
Graph
StandardRelationType.DEFAULT
public Edge<V> newEdge(RelationType type, String label, V sourceNode, V destinationNode)
Graph
public Edge<V> addEdge(RelationType type, String id, String label, V sourceNode, V destinationNode) throws IllegalArgumentException
Graph
IllegalArgumentException
addEdge
in interface Graph<V extends Node<V>>
type
- the type of the edgeid
- the idlabel
- the edge labelsourceNode
- the source nodedestinationNode
- the destination nodeIllegalArgumentException
- if a edge instance with the given id but a different type exists already. Or if
source or destination node is null
public Edge<V> addEdge(String id, String label, V sourceNode, V destinationNode) throws IllegalArgumentException
Graph
StandardRelationType.DEFAULT
public V getNode(String id)
Graph
public Edge<V> getEdge(String id)
Graph
public Set<V> getNodes()
Graph
public List<V> findNodes(String query)
Graph
public void removeNode(V node)
removeNode
in interface Graph<V extends Node<V>>
public void removeEdge(Edge<V> edge)
Graph
removeEdge
in interface Graph<V extends Node<V>>
edge
- the edge to removeCopyright © 2006–2019 The Apache Software Foundation. All rights reserved.