N - The class representing the nodes of the graphE - The class representing the edges of the graphpublic interface Graph<N,E>
An object which provides relationships between two objects. This interface provides implementation details for the Graph data structure as defined in formal mathematics and computer science theory. Specifically, a graph is defined as a set objects (the nodes) and relations between those objects (the Edges). The graph function G:(N,E,g) is defined so that if g(n1, n2) = e, the edge e is said to connect n1 and n2. The size of a graph is defined to be its number of edges. The number of nodes of a graph is the order of the graph.
A graph can be of two types, directed or undirected. An undirected graph is a graph where the ordering of the nodes defining an edge is not significant, and may be reversed. Formally, g(n1,n2)=g(n2,n1). A directed graph is a graph where g(n1,n2) != g(n2, n1).
This interface implements graphs on arbitrary objects, and conforms to the conventions of the Collections interfaces. It uses generics to allow specific implementations of graphs on specific objects.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
Graph.Segment<N,E>
Edge segments are composed of an edge and its two connected nodes.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(N node)
Add a node to the graph
|
void |
addAll(Graph<? extends N,? extends E> graph)
Add all elements from the specified graph to this graph.
|
boolean |
addEdge(E edge,
N orig,
N dest)
Add the edge element to the graph.
|
void |
clear()
Clear all nodes and edges from this graph
|
boolean |
contains(java.lang.Object obj)
Determines whether the given object is a node within this graph.
|
boolean |
containsEdge(java.lang.Object obj)
Determines whether the given object is an edge within this graph.
|
java.util.Iterator<E> |
edgeIterator()
Return an iterator over the set of edges for this graph.
|
boolean |
equals(java.lang.Object obj)
Determine whether another object is the same as this graph.
|
E |
getEdge(N n1,
N n2)
Get the edge between two nodes
|
Graph.Segment<N,E> |
getEdgeSegment(E edge)
Get the edge segment for the specified edge
|
java.util.Set<E> |
getEdgeSet()
Get the set of edges for this graph
|
java.util.Set<E> |
getNodeEdges(N node)
Get the set of edges which connect to a particular node.
|
java.util.Set<N> |
getNodeSet()
Get the set of nodes for this graph
|
java.util.Set<Graph.Segment<N,E>> |
getSegmentSet()
Get the set of edge segments for this graph
|
int |
hashCode()
Get the hashcode for this graph
|
boolean |
isDirected()
Return whether this graph is a directed graph
|
boolean |
isEmpty()
Return whether the graph is empty.
|
java.util.Iterator<N> |
iterator()
Return an iterator over the set of nodes for this graph.
|
int |
order()
Return the order of the graph.
|
boolean |
remove(java.lang.Object obj)
Remove an object from the graph.
|
boolean |
removeEdge(java.lang.Object edge)
Remove the edge from the graph
|
int |
size()
Return the size of the graph.
|
boolean add(N node)
node - the node to addvoid addAll(Graph<? extends N,? extends E> graph)
graph - the graph to addboolean addEdge(E edge, N orig, N dest)
edge - the edge to addorig - the origin nodedest - the destination nodevoid clear()
boolean contains(java.lang.Object obj)
obj - the object to testboolean containsEdge(java.lang.Object obj)
obj - the object to testjava.util.Iterator<E> edgeIterator()
boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the object to testE getEdge(N n1, N n2)
n1 - The first noden2 - The second nodeGraph.Segment<N,E> getEdgeSegment(E edge)
edge - the edgejava.util.Set<E> getEdgeSet()
java.util.Set<E> getNodeEdges(N node)
node - the node to checkjava.util.Set<N> getNodeSet()
java.util.Set<Graph.Segment<N,E>> getSegmentSet()
int hashCode()
hashCode in class java.lang.Objectboolean isDirected()
boolean isEmpty()
java.util.Iterator<N> iterator()
int order()
boolean remove(java.lang.Object obj)
obj - the object to removeboolean removeEdge(java.lang.Object edge)
edge - the edge to removeint size()