public class Graph extends Object
Graph representation using the adjacency list form. See the book 'Introduction to Algorithms' by Cormen, Leiserson, and Rivest.
Constructor and Description |
---|
Graph() |
Modifier and Type | Method and Description |
---|---|
void |
addEdge(Edge edge)
Add an edge to the graph.
|
void |
addNode(Object node)
Add a node to the graph.
|
void |
clear()
Clear the graph.
|
void |
clearTraversal()
Clear all nodes and edges of the bookkeeping information from their
last traversal.
|
boolean |
containsNode(Object node)
Return true if the graph contains the given node.
|
Collection<Edge> |
getEdges()
Return all edges in the graph.
|
Collection<Edge> |
getEdges(Object from,
Object to)
Return all the edges from one node to another.
|
Collection<Edge> |
getEdgesFrom(Object node)
Return all the edges from a particular node.
|
Collection<Edge> |
getEdgesTo(Object node)
Return all the edges to a particular node.
|
Collection<Object> |
getNodes()
Return a view of all nodes in the graph.
|
boolean |
removeEdge(Edge edge)
Remove an edge from the graph.
|
boolean |
removeNode(Object node)
Remove a node from the graph.
|
public void clear()
public boolean containsNode(Object node)
public Collection<Object> getNodes()
public void addNode(Object node)
public boolean removeNode(Object node)
public Collection<Edge> getEdges()
public Collection<Edge> getEdgesFrom(Object node)
public Collection<Edge> getEdgesTo(Object node)
public Collection<Edge> getEdges(Object from, Object to)
public void addEdge(Edge edge)
public boolean removeEdge(Edge edge)
public void clearTraversal()
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.