|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
N - the type of nodes contained in this graphE - the type of edges contained in this graphpublic interface Graph<N,E>
As implied by its name, this interface models the mathematical graph abstraction. A graph G(N,E) contains a set of nodes N and a set of edges E. Each edge e=(n1,n2) in E connects node n1 to node n2.
| Method Summary | |
|---|---|
boolean |
addAllEdges(Collection<E> edges)
Adds all of the edges in the specified collection to this graph if they are not already present (optional operation). |
boolean |
addAllNodes(Collection<N> nodes)
Adds all of the nodes in the specified collection to this graph if they are not already present (optional operation). |
boolean |
addEdge(E edge)
Adds the specified edge to this graph if it is not already present (optional operation). |
boolean |
addNode(N node)
Adds the specified node to this graph if it is not already present (optional operation). |
void |
clear()
Removes all nodes and all edges from this graph (optional operation). |
boolean |
containsAllEdges(Collection<E> edges)
Returns true if this graph contains all of the edges of the specified collection. |
boolean |
containsAllNodes(Collection<N> nodes)
Returns true if this graph contains all of the nodes of the specified collection. |
boolean |
containsEdge(E edge)
Returns true if this graph contains the specified edge. |
boolean |
containsEdge(N source,
N target)
Returns true if this graph contains the specified edge e=(source,target). |
boolean |
containsNode(N node)
Returns true if this graph contains the specified node. |
E |
createEdge(N source,
N target)
Creates a new edge from the specified source node to the target node, adds it to this graph and returns the created edge. |
N |
createNode()
Creates a new node, adds it to this graph and returns the created node. |
Set<E> |
edges()
Returns an unmodifiable Set view of the edges contained in this graph. |
Set<E> |
edges(GraphElementFilter<? super E> filter)
Returns an unmodifiable Set view of the edges contained in this graph that satisfy the specified filter. |
int |
edgeSize()
Returns the number of edges in this graph, i.e. the cardinality of the set of edges. |
E |
getEdge(N source,
N target)
Returns the edge e=(source,target) from the specified source node to the target node, or null if this graph contains no such edge. |
Set<E> |
incomingEdges(N node)
Returns the set of all incoming edges of the specified node. |
boolean |
isEmpty()
Returns true if this graph contains no elements. |
Set<N> |
neighbors(N node)
Returns the set of all neighbors of the specified node. |
Set<N> |
nodes()
Returns an unmodifiable Set view of the nodes contained in this graph. |
Set<N> |
nodes(GraphElementFilter<? super N> filter)
Returns an unmodifiable Set view of the nodes contained in this graph that satisfy the specified filter. |
int |
nodeSize()
Returns the number of nodes in this graph, i.e. the cardinality of the set of nodes. |
Set<E> |
outgoingEdges(N node)
Returns the set of all outgoing edges of the specified node. |
boolean |
removeAllEdges(Collection<E> edges)
Removes from this graph all of its edges that are contained in the specified collection (optional operation). |
boolean |
removeAllNodes(Collection<N> nodes)
Removes from this graph all of its nodes that are contained in the specified collection (optional operation). |
boolean |
removeEdge(E edge)
Removes the specified edge e from this graph if it is present (optional operation). |
boolean |
removeEdge(N source,
N target)
Removes the edge e=(source,target) connecting the specified source and target node from this graph if it is present (optional operation). |
boolean |
removeNode(N node)
Removes the specified node n from this graph if it is present (optional operation). |
boolean |
retainAllEdges(Collection<E> edges)
Retains only the edges in this graph that are contained in the specified collection (optional operation). |
boolean |
retainAllNodes(Collection<N> nodes)
Retains only the nodes in this graph that are contained in the specified collection (optional operation). |
| Methods inherited from interface java.lang.Iterable |
|---|
iterator |
| Method Detail |
|---|
int nodeSize()
int edgeSize()
boolean isEmpty()
boolean containsNode(N node)
node - node whose presence in this graph is to be tested
NullPointerException - if the specified node is null (optional)boolean containsEdge(E edge)
edge - edge whose presence in this graph is to be tested
NullPointerException - if the specified edge is null (optional)
boolean containsEdge(N source,
N target)
source - the source node of the edge whose presence in this graph is to be testedtarget - the target node of the edge whose presence in this graph is to be tested
NullPointerException - if the specified source node or target node is null (optional)boolean containsAllNodes(Collection<N> nodes)
nodes - collection of nodes to be checked for containment in this graph
NullPointerException - if the specified collection contains one or more null elements, or if the specified
collection is null (optional)containsNode(Object)boolean containsAllEdges(Collection<E> edges)
edges - collection of edges to be checked for containment in this graph
NullPointerException - if the specified collection contains one or more null elements, or if the specified
collection is null (optional)containsEdge(Object)Set<N> nodes()
Set view of the nodes contained in this graph. The set is backed by the graph, so
changes to the graph are reflected in the set. If the graph is modified while an iteration over the set is in
progress, the results of the iteration are undefined.
Set<N> nodes(GraphElementFilter<? super N> filter)
Set view of the nodes contained in this graph that satisfy the specified filter.
The behavior of this method is the same as that of the nodes() method, except that the
nodes in the returned set must satisfy the filter and the set is not backed by the graph, i.e. changes to the
graph are not reflected in the set. If the given filter is null then all nodes are
accepted. Otherwise, a node satisfies the filter if and only if the value true results when the
GraphElementFilter.accept(E) method of the filter is invoked on the node.
filter - a node filter
Set<E> edges()
Set view of the edges contained in this graph. The set is backed by the graph, so
changes to the graph are reflected in the set. If the graph is modified while an iteration over the set is in
progress, the results of the iteration are undefined.
Set<E> edges(GraphElementFilter<? super E> filter)
Set view of the edges contained in this graph that satisfy the specified filter.
The behavior of this method is the same as that of the edges() method, except that the
edges in the returned set must satisfy the filter and the set is not backed by the graph, i.e. changes to the
graph are not reflected in the set. If the given filter is null then all edges are
accepted. Otherwise, an edge satisfies the filter if and only if the value true results when the
GraphElementFilter.accept(E) method of the filter is invoked on the edge.
filter - an edge filter
E getEdge(N source,
N target)
More formally, if this graph contains an edge e* such that e.equals(e*), where e=(source,target), then this method returns e*, otherwise it returns null.
source - the source node of the edge that is to be returnedtarget - the target node of the edge that is to be returned
NullPointerException - if the specified source node or target node is null (optional)Set<E> outgoingEdges(N node)
More formally, this method returns all edges e in this graph such that the given node is the source node of e, i.e. e=(node,*).
node - the source node
NullPointerException - if the specified node is null (optional)Set<E> incomingEdges(N node)
More formally, this method returns all edges e in this graph such that the given node is the target node of e, i.e. e=(*,node).
node - the target node
NullPointerException - if the specified node is null (optional)Set<N> neighbors(N node)
node - the node of which all neighboring nodes are to be returned
NullPointerException - if the specified node is null (optional)N createNode()
UnsupportedOperationException - if the createNode operation is not supported by this graph
E createEdge(N source,
N target)
source - the source node of the edge that is to be createdtarget - the target node of the edge that is to be created
UnsupportedOperationException - if the createEdge operation is not supported by this graph
NullPointerException - if the specified source or target node is null
IllegalArgumentException - if some property of the specified nodes prevents them from being added to this graphboolean addNode(N node)
More formally, adds the specified node n to this graph if the graph contains no element n2 such that n.equals(n2)) . If this graph already contains the element, the call leaves the graph unchanged and returns false.
node - node to be added to this graph
UnsupportedOperationException - if the addNode operation is not supported by this graph
NullPointerException - if the specified node is null
IllegalArgumentException - if some property of the specified node prevents it from being added to this graphboolean addEdge(E edge)
More formally, adds the specified edge e to this graph if the graph contains no element e2 such that e.equals(e2)) . If this graph already contains the element, the call leaves the graph unchanged and returns false.
edge - edge to be added to this graph
UnsupportedOperationException - if the addEdge operation is not supported by this graph
NullPointerException - if the specified edge is null
IllegalArgumentException - if some property of the specified edge prevents it from being added to this graphboolean addAllNodes(Collection<N> nodes)
If the specified collection is a set, the addAllNodes operation effectively modifies the set of nodes so that its value is the union of the two sets. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress.
nodes - collection containing nodes to be added to this graph
UnsupportedOperationException - if the addAllNodes operation is not supported by this graph
NullPointerException - if the specified collection contains one or more null elements, or if the specified
collection is null
IllegalArgumentException - if some property of a node in the specified collection prevents it from being added to this graphaddNode(Object)boolean addAllEdges(Collection<E> edges)
If the specified collection is a set, the addAllEdges operation effectively modifies the set of edges so that its value is the union of the two sets. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress.
edges - collection containing edges to be added to this graph
UnsupportedOperationException - if the addAllEdges operation is not supported by this graph
NullPointerException - if the specified collection contains one or more null elements, or if the specified
collection is null
IllegalArgumentException - if some property of an edge in the specified collection prevents it from being added to this graphaddEdge(Object)boolean removeNode(N node)
More formally, removes a node n* such that n.equals(n*) , if this graph contains such a node. Furthermore, all edges incident to this node are removed. Returns true if this graph contained the node (or equivalently, if this graph changed as a result of the call).
node - node to be removed from this graph, if present
NullPointerException - if the specified node is null (optional)
UnsupportedOperationException - if the removeNode operation is not supported by this graphboolean removeEdge(E edge)
More formally, removes an edge e* such that e.equals(e*), if this graph contains such an edge. Returns true if this graph contained the edge (or equivalently, if this graph changed as a result of the call).
edge - edge to be removed from this graph, if present
NullPointerException - if the specified edge is null (optional)
UnsupportedOperationException - if the removeEdge operation is not supported by this graph
boolean removeEdge(N source,
N target)
More formally, removes an edge e* such that e.equals(e*), where e=(source,target), if this graph contains such an edge. Returns true if this graph contained the edge (or equivalently, if this graph changed as a result of the call).
source - the source node of the edge that is to be removedtarget - the target node of the edge that is to be removed
NullPointerException - if the specified source node or target node is null (optional)
UnsupportedOperationException - if the removeEdge operation is not supported by this graphboolean removeAllNodes(Collection<N> nodes)
If the specified collection is a set, this operation effectively modifies the set of nodes so that its value is the asymmetric set difference of the two sets.
nodes - collection containing nodes to be removed from this graph
UnsupportedOperationException - if the removeAllNodes operation is not supported by this graph
NullPointerException - if the specified collection contains one or more null elements, or if the specified
collection is null (optional)removeNode(Object)boolean removeAllEdges(Collection<E> edges)
If the specified collection is a set, this operation effectively modifies the set of edges so that its value is the asymmetric set difference of the two sets.
edges - collection containing edges to be removed from this graph
UnsupportedOperationException - if the removeAllEdges operation is not supported by this graph
NullPointerException - if the specified collection contains one or more null elements, or if the specified
collection is null (optional)removeEdge(Object)boolean retainAllNodes(Collection<N> nodes)
In other words, removes from this graph all of its nodes that are not contained in the specified collection. If the specified collection is a set, this operation effectively modifies the set of nodes so that its value is the intersection of the two sets.
nodes - collection containing nodes to be retained in this graph
UnsupportedOperationException - if the retainAllNodes operation is not supported by this graph
NullPointerException - if the specified collection contains one or more null elements, or if the specified
collection is null (optional)removeNode(Object),
removeAllNodes(Collection)boolean retainAllEdges(Collection<E> edges)
In other words, removes from this graph all of its edges that are not contained in the specified collection. If the specified collection is a set, this operation effectively modifies the set of edges so that its value is the intersection of the two sets.
edges - collection containing edges to be retained in this graph
UnsupportedOperationException - if the retainAllEdges operation is not supported by this graph
NullPointerException - if the specified collection contains one or more null elements, or if the specified
collection is null (optional)removeEdge(Object),
removeAllEdges(Collection)void clear()
UnsupportedOperationException - if the clear method is not supported by this graph
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||