javautils.graph
Class GraphDecorator

java.lang.Object
  |
  +--javautils.graph.GraphDecorator
All Implemented Interfaces:
Graph
Direct Known Subclasses:
AnAugmentedGraph, AugmentedGraphDecorator, UndirectedGraph

public class GraphDecorator
extends java.lang.Object
implements Graph

A basic forwarding Decorator, see [Gamma1995], for the Graph-interface. By default, the decorator simply forwards all operations to the original graph given at construction time. A class derived from the decorator can then override operations to alter the behavior of the graph.

Since a derived decorator is allowed to alter the behavior of the graph in any way, like adding nodes or removing edges, it is generally not safe to make any assumptions about the relationship between the original and the decorated graph.

See Also:
AugmentedGraphDecorator

Constructor Summary
GraphDecorator(Graph graph)
           
 
Method Summary
 java.util.List edgesFrom(java.lang.Object node)
          List of all edges from the specified source node.
protected  Graph graph()
          The original graph.
 java.util.List nodes()
          List of all nodes.
 java.lang.Object sourceOf(java.lang.Object edge)
          The source node of the edge.
 java.lang.Object targetOf(java.lang.Object edge)
          The target node of the edge.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphDecorator

public GraphDecorator(Graph graph)
Method Detail

nodes

public java.util.List nodes()
Description copied from interface: Graph

List of all nodes.

Important: This method should have O(1) time complexity. This means that you should avoid constructing the list each time this method is called.

Note: The order of nodes in the returned list may have an effect on the results of graph algorithms.

Specified by:
nodes in interface Graph

edgesFrom

public java.util.List edgesFrom(java.lang.Object node)
Description copied from interface: Graph

List of all edges from the specified source node.

Important: This method should have O(1) time complexity. This means that you should avoid constructing the list each time this method is called.

Note: The order of edges in the returned list may have an effect on the results of graph algorithms.

Specified by:
edgesFrom in interface Graph

targetOf

public java.lang.Object targetOf(java.lang.Object edge)
Description copied from interface: Graph

The target node of the edge.

Specified by:
targetOf in interface Graph

sourceOf

public java.lang.Object sourceOf(java.lang.Object edge)
Description copied from interface: Graph

The source node of the edge.

Specified by:
sourceOf in interface Graph

graph

protected final Graph graph()

The original graph.