public class DirectedGraph<N> extends Object implements Cloneable
Constructor and Description |
---|
DirectedGraph() |
Modifier and Type | Method and Description |
---|---|
void |
addEdge(N a,
N b)
Adds a directed edge into the network from a to b.
|
void |
addNode(N node)
Adds a new node to the graph
|
void |
addNodes(Collection<? extends N> c)
Adds all the objects in c as nodes in the graph
|
protected DirectedGraph<N> |
clone() |
boolean |
containsNode(N a)
Returns true if a is a node in the graph, or false otherwise.
|
Set<N> |
getChildren(N n)
Returns the set of all children of the requested node, or null if the node does not exist in the graph.
|
Set<N> |
getNodes()
Returns the set of all nodes currently in the graph
|
Set<N> |
getParents(N n)
Returns the set of all parents of the requested node, or null if the node does not exist in the graph
|
void |
removeEdge(N a,
N b)
Removes a directed edge from the network connecting a to b.
|
void |
removeNode(N node)
Removes the specified node from the graph.
|
public Set<N> getNodes()
public void addNodes(Collection<? extends N> c)
c
- a collection of nodes to addpublic void addNode(N node)
node
- the object to make a nodepublic Set<N> getParents(N n)
n
- the node to obtain the parents ofpublic Set<N> getChildren(N n)
n
- the node to obtain the children ofpublic void removeNode(N node)
node
- the node to remove from the graphpublic void addEdge(N a, N b)
a
- the parent nodeb
- the child nodepublic void removeEdge(N a, N b)
a
- the parent nodeb
- the child nodepublic boolean containsNode(N a)
a
- the node in questionprotected DirectedGraph<N> clone()
Copyright © 2017. All rights reserved.