org.dishevelled.graph
Interface Graph<N,E>

Type Parameters:
N - node value type
E - edge value type
All Known Implementing Classes:
AbstractGraphDecorator, GraphImpl

public interface Graph<N,E>

Directed graph with typed values on nodes and edges.

Version:
$Revision$ $Date$
Author:
Michael Heuer

Method Summary
 void clear()
          Clear the nodes and edges in this graph (optional operation).
 Edge<N,E> createEdge(Node<N,E> source, Node<N,E> target, E value)
          Create and return a new edge in this graph with the specified value connecting the specified source and target nodes (optional operation).
 Node<N,E> createNode(N value)
          Create and return a new node in this graph with the specified value (optional operation).
 int edgeCount()
          Return the number of edges in this graph.
<T> Map<Edge<N,E>,T>
edgeMap(T defaultValue)
          Return a map of type <Edge<N, E>, T> with the edges in this graph as keys.
 Set<Edge<N,E>> edges()
          Return a read-only set view of the edges in this graph.
 Collection<E> edgeValues()
          Return a read-only collection view of the edge values in this graph.
 void forEachEdge(UnaryPredicate<Edge<N,E>> predicate, UnaryProcedure<Edge<N,E>> procedure)
          Apply the specified procedure to each edge in this graph accepted by the specified predicate.
 void forEachEdge(UnaryProcedure<Edge<N,E>> procedure)
          Apply the specified procedure to each edge in this graph.
 void forEachEdgeValue(UnaryPredicate<E> predicate, UnaryProcedure<E> procedure)
          Apply the specified procedure to each edge value in this graph accepted by the specified predicate.
 void forEachEdgeValue(UnaryProcedure<? super E> procedure)
          Apply the specified procedure to each edge value in this graph.
 void forEachNode(UnaryPredicate<Node<N,E>> predicate, UnaryProcedure<Node<N,E>> procedure)
          Apply the specified procedure to each node in this graph accepted by the specified predicate.
 void forEachNode(UnaryProcedure<Node<N,E>> procedure)
          Apply the specified procedure to each node in this graph.
 void forEachNodeValue(UnaryPredicate<N> predicate, UnaryProcedure<N> procedure)
          Apply the specified procedure to each node value in this graph accepted by the specified predicate.
 void forEachNodeValue(UnaryProcedure<? super N> procedure)
          Apply the specified procedure to each node value in this graph.
 boolean isEmpty()
          Return true if this graph is empty.
 int nodeCount()
          Return the number of nodes in this graph.
<T> Map<Node<N,E>,T>
nodeMap(T defaultValue)
          Return a map of type <Node<N, E>, T> with the nodes in this graph as keys.
 Set<Node<N,E>> nodes()
          Return a read-only set view of the nodes in this graph.
 Collection<N> nodeValues()
          Return a read-only collection view of the node values in this graph.
 void remove(Edge<N,E> edge)
          Remove the specified edge from this graph (optional operation).
 void remove(Node<N,E> node)
          Remove the specified node and any edges connecting the node from this graph (optional operation).
 

Method Detail

isEmpty

boolean isEmpty()
Return true if this graph is empty.

Returns:
true if this graph is empty

nodeCount

int nodeCount()
Return the number of nodes in this graph.

Returns:
the number of nodes in this graph

nodes

Set<Node<N,E>> nodes()
Return a read-only set view of the nodes in this graph. The view may be empty (if nodeCount() == 0) but will not be null.

Returns:
a read-only set view of the nodes in this graph

nodeValues

Collection<N> nodeValues()
Return a read-only collection view of the node values in this graph. The view may be empty (if nodeCount() == 0) but will not be null.

Returns:
a read-only collection view of the node values in this graph

nodeMap

<T> Map<Node<N,E>,T> nodeMap(T defaultValue)
Return a map of type <Node<N, E>, T> with the nodes in this graph as keys. The keys in the returned map reference the nodes in this graph and are read-only. Each key maps to the specified default value, which may be null. The map may be empty (if nodeCount() == 0) but will not be null.

Type Parameters:
T - node map value type
Parameters:
defaultValue - default value for each node mapping
Returns:
a map of type <Node<N, E>, T> with the nodes in this graph as keys

forEachNode

void forEachNode(UnaryProcedure<Node<N,E>> procedure)
Apply the specified procedure to each node in this graph.

Parameters:
procedure - procedure to apply, must not be null

forEachNode

void forEachNode(UnaryPredicate<Node<N,E>> predicate,
                 UnaryProcedure<Node<N,E>> procedure)
Apply the specified procedure to each node in this graph accepted by the specified predicate.

Parameters:
predicate - node predicate, must not be null
procedure - procedure to apply, must not be null

forEachNodeValue

void forEachNodeValue(UnaryProcedure<? super N> procedure)
Apply the specified procedure to each node value in this graph.

Parameters:
procedure - procedure to apply, must not be null

forEachNodeValue

void forEachNodeValue(UnaryPredicate<N> predicate,
                      UnaryProcedure<N> procedure)
Apply the specified procedure to each node value in this graph accepted by the specified predicate.

Parameters:
predicate - node value predicate, must not be null
procedure - procedure to apply, must not be null

edgeCount

int edgeCount()
Return the number of edges in this graph.

Returns:
the number of edges in this graph

edges

Set<Edge<N,E>> edges()
Return a read-only set view of the edges in this graph. The view may be empty (if edgeCount() == 0) but will not be null.

Returns:
a read-only set view of the edges in this graph

edgeValues

Collection<E> edgeValues()
Return a read-only collection view of the edge values in this graph. The view may be empty (if edgeCount() == 0) but will not be null.

Returns:
a read-only collection view of the edge values in this graph

edgeMap

<T> Map<Edge<N,E>,T> edgeMap(T defaultValue)
Return a map of type <Edge<N, E>, T> with the edges in this graph as keys. The keys in the returned map reference the edges in this graph and are read-only. Each key maps to the specified default value, which may be null. The map may be empty (if edgeCount() == 0) but will not be null.

Type Parameters:
T - edge map value type
Parameters:
defaultValue - default value for each edge mapping
Returns:
a map of type <Edge<N, E>, T> with the edges in this graph as keys

forEachEdge

void forEachEdge(UnaryProcedure<Edge<N,E>> procedure)
Apply the specified procedure to each edge in this graph.

Parameters:
procedure - procedure to apply, must not be null

forEachEdge

void forEachEdge(UnaryPredicate<Edge<N,E>> predicate,
                 UnaryProcedure<Edge<N,E>> procedure)
Apply the specified procedure to each edge in this graph accepted by the specified predicate.

Parameters:
predicate - edge predicate, must not be null
procedure - procedure to apply, must not be null

forEachEdgeValue

void forEachEdgeValue(UnaryProcedure<? super E> procedure)
Apply the specified procedure to each edge value in this graph.

Parameters:
procedure - procedure to apply, must not be null

forEachEdgeValue

void forEachEdgeValue(UnaryPredicate<E> predicate,
                      UnaryProcedure<E> procedure)
Apply the specified procedure to each edge value in this graph accepted by the specified predicate.

Parameters:
predicate - edge value predicate, must not be null
procedure - procedure to apply, must not be null

clear

void clear()
Clear the nodes and edges in this graph (optional operation).

Throws:
UnsupportedOperationException - if the clear operation is not supported by this graph

createNode

Node<N,E> createNode(N value)
Create and return a new node in this graph with the specified value (optional operation).

Parameters:
value - value
Returns:
a new node in this graph with the specified value
Throws:
UnsupportedOperationException - if the createNode operation is not supported by this graph

remove

void remove(Node<N,E> node)
Remove the specified node and any edges connecting the node from this graph (optional operation).

Parameters:
node - node to remove, must not be null and must be contained in this graph
Throws:
UnsupportedOperationException - if the remove(Node) operation is not supported by this graph

createEdge

Edge<N,E> createEdge(Node<N,E> source,
                     Node<N,E> target,
                     E value)
Create and return a new edge in this graph with the specified value connecting the specified source and target nodes (optional operation).

Parameters:
value - value
source - source node, must not be null and must be contained in this graph
target - target node, must not be null and must be contained in this graph
Returns:
a new edge in this graph with the specified value connecting the specified source and target nodes
Throws:
UnsupportedOperationException - if the createEdge operation is not supported by this graph

remove

void remove(Edge<N,E> edge)
Remove the specified edge from this graph (optional operation).

Parameters:
edge - edge to remove, must not be null and must be contained in this graph
Throws:
UnsupportedOperationException - if the remove(Edge) operation is not supported by this graph


Copyright (c) 2004-2012 held jointly by the individual authors. Licensed under the GNU Lesser General Public License (LGPL).