javautils.graph
Class GraphContract

java.lang.Object
  |
  +--javautils.graph.GraphDecorator
        |
        +--javautils.graph.AugmentedGraphDecorator
              |
              +--javautils.graph.GraphContract
All Implemented Interfaces:
AugmentedGraph, Graph

public final class GraphContract
extends AugmentedGraphDecorator

A Design-by-Contract [Meyer1997] decorator for the AugmentedGraph-interface. This decorator checks the graph invariant only once upon construction and then checks only the preconditions each time a method is called.


Method Summary
 java.util.List edgesFrom(java.lang.Object node)
          List of all edges from the specified source node.
 java.util.List edgesTo(java.lang.Object node)
          List of all edges to the specified target node.
static GraphContract from(AugmentedGraph graph)
          A contract checking version of the given graph.
 boolean isEdge(java.lang.Object obj)
          True if and only if the object is an edge of this graph.
 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 javautils.graph.AugmentedGraphDecorator
augmented, isNode
 
Methods inherited from class javautils.graph.GraphDecorator
graph, nodes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javautils.graph.adt.Graph
nodes
 

Method Detail

from

public static GraphContract from(AugmentedGraph graph)

A contract checking version of the given graph. If the graph is already a contract checking graph, then the given graph is simply returned.


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
Overrides:
edgesFrom in class GraphDecorator

edgesTo

public java.util.List edgesTo(java.lang.Object node)
Description copied from interface: AugmentedGraph

List of all edges to the specified target 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:
edgesTo in interface AugmentedGraph
Overrides:
edgesTo in class AugmentedGraphDecorator

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
Overrides:
sourceOf in class GraphDecorator

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
Overrides:
targetOf in class GraphDecorator

isEdge

public boolean isEdge(java.lang.Object obj)

True if and only if the object is an edge of this graph.