Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.phoenixst.plexus.operations
Class Product  view Product download Product.java

java.lang.Object
  extended bycom.phoenixst.plexus.AbstractGraph
      extended bycom.phoenixst.plexus.operations.Product
All Implemented Interfaces:
com.phoenixst.plexus.Graph, java.io.Serializable

public class Product
extends com.phoenixst.plexus.AbstractGraph
implements java.io.Serializable

A Graph which is the product of two other Graphs. The nodes are immutable java.util.List objects with exactly two elements, the first element being a node from the first graph and the second being a node from the second graph. Note: At the present time, only undirected simple graphs may be used.

If either wrapped Graph contains Edges which point to other Edges, the product will not reflect this. The node and edge aspects of any such Edge will be distinct in the product.

Since:
1.0
Version:
$Revision: 1.14 $

Nested Class Summary
private  class Product.AllEdgesIteratorImpl
           
private  class Product.EdgeImpl
          An immutable Edge that wraps an edge from one of the argument graphs, but uses a tail and head from this graph.
private  class Product.EdgeIteratorImpl
           
private  class Product.NodeIterator
           
private static class Product.OrderedPair
          A simple immutable ordered pair implementation.
private  class Product.TraverserImpl
           
 
Nested classes inherited from class com.phoenixst.plexus.AbstractGraph
com.phoenixst.plexus.AbstractGraph.ChainTraverser
 
Nested classes inherited from class com.phoenixst.plexus.Graph
com.phoenixst.plexus.Graph.Edge
 
Field Summary
private  com.phoenixst.plexus.Graph a
           
private  com.phoenixst.plexus.Graph b
           
 
Constructor Summary
Product(com.phoenixst.plexus.Graph a, com.phoenixst.plexus.Graph b)
          Creates a new Product graph.
 
Method Summary
private  java.util.List checkNode(java.lang.Object node)
           
private  java.util.List checkNodeType(java.lang.Object node)
           
 void clear()
          Throws an UnsupportedOperationException.
 boolean containsNode(java.lang.Object node)
          Returns true if this Graph contains node.
 int degree(java.lang.Object node)
          Returns the degree of node, defined as the number of edges incident on node, with self-loops counted twice.
 java.util.Iterator edgeIterator()
          Returns an Iterator over all the Edges in this Graph.
 java.util.Iterator edgeIterator(java.lang.Object tail, java.lang.Object head)
          Returns an Iterator over all the edges from tail to head.
 int edgeSize()
          Returns the number of edges in this Graph.
private static boolean equals(java.lang.Object a, java.lang.Object b)
           
 com.phoenixst.plexus.Graph.Edge getEdge(java.lang.Object tail, java.lang.Object head)
          Returns the edge from tail to head, or null if it does not exist.
 com.phoenixst.plexus.Graph getLeftOperand()
           
 com.phoenixst.plexus.Graph getRightOperand()
           
 boolean isDirected()
          Returns false.
 boolean isSimple()
          Returns true.
 java.util.Iterator nodeIterator()
          Returns an Iterator over all the nodes in this Graph.
 int nodeSize()
          Returns the number of nodes in this Graph.
 boolean removeEdge(com.phoenixst.plexus.Graph.Edge edge)
          Throws an UnsupportedOperationException.
 boolean removeNode(java.lang.Object node)
          Throws an UnsupportedOperationException.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 com.phoenixst.plexus.Traverser traverser(java.lang.Object node)
          Returns a com.phoenixst.plexus.Traverser from node to all adjacent nodes.
 
Methods inherited from class com.phoenixst.plexus.AbstractGraph
addEdge, addNode, containsEdge, inDegree, inTraverser, isEmpty, iteratorClear, iteratorContains, iteratorCount, iteratorRemove, outDegree, outTraverser
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

a

private com.phoenixst.plexus.Graph a

b

private com.phoenixst.plexus.Graph b
Constructor Detail

Product

public Product(com.phoenixst.plexus.Graph a,
               com.phoenixst.plexus.Graph b)
Creates a new Product graph.

Method Detail

getLeftOperand

public com.phoenixst.plexus.Graph getLeftOperand()

getRightOperand

public com.phoenixst.plexus.Graph getRightOperand()

equals

private static final boolean equals(java.lang.Object a,
                                    java.lang.Object b)

checkNodeType

private java.util.List checkNodeType(java.lang.Object node)

checkNode

private java.util.List checkNode(java.lang.Object node)

isDirected

public boolean isDirected()
Returns false.

Specified by:
isDirected in interface com.phoenixst.plexus.Graph

isSimple

public boolean isSimple()
Returns true.

Specified by:
isSimple in interface com.phoenixst.plexus.Graph

nodeSize

public int nodeSize()
Returns the number of nodes in this Graph.

Specified by:
nodeSize in interface com.phoenixst.plexus.Graph

edgeSize

public int edgeSize()
Returns the number of edges in this Graph.

Specified by:
edgeSize in interface com.phoenixst.plexus.Graph

degree

public int degree(java.lang.Object node)
Returns the degree of node, defined as the number of edges incident on node, with self-loops counted twice.

Specified by:
degree in interface com.phoenixst.plexus.Graph

removeNode

public boolean removeNode(java.lang.Object node)
Throws an UnsupportedOperationException.

Specified by:
removeNode in interface com.phoenixst.plexus.Graph

containsNode

public boolean containsNode(java.lang.Object node)
Returns true if this Graph contains node.

Specified by:
containsNode in interface com.phoenixst.plexus.Graph

removeEdge

public boolean removeEdge(com.phoenixst.plexus.Graph.Edge edge)
Throws an UnsupportedOperationException.

Specified by:
removeEdge in interface com.phoenixst.plexus.Graph

getEdge

public com.phoenixst.plexus.Graph.Edge getEdge(java.lang.Object tail,
                                               java.lang.Object head)
Returns the edge from tail to head, or null if it does not exist.

Specified by:
getEdge in interface com.phoenixst.plexus.Graph

clear

public void clear()
Throws an UnsupportedOperationException.

Specified by:
clear in interface com.phoenixst.plexus.Graph

nodeIterator

public java.util.Iterator nodeIterator()
Description copied from interface: com.phoenixst.plexus.Graph
Returns an Iterator over all the nodes in this Graph. Calling Iterator.remove()>Iterator.remove() 55 removes the last node returned by the Iterator, and all edges incident upon that node, from this Graph. There are no guarantees concerning the order in which the nodes are returned (unless this Graph is an instance of some class that provides a guarantee).

Specified by:
nodeIterator in interface com.phoenixst.plexus.Graph

edgeIterator

public java.util.Iterator edgeIterator()
Description copied from interface: com.phoenixst.plexus.Graph
Returns an Iterator over all the Edges in this Graph. There are no guarantees concerning the order in which the edges are returned (unless this Graph is an instance of some class that provides a guarantee).

Specified by:
edgeIterator in interface com.phoenixst.plexus.Graph

edgeIterator

public java.util.Iterator edgeIterator(java.lang.Object tail,
                                       java.lang.Object head)
Returns an Iterator over all the edges from tail to head.

Specified by:
edgeIterator in interface com.phoenixst.plexus.Graph

traverser

public com.phoenixst.plexus.Traverser traverser(java.lang.Object node)
Returns a com.phoenixst.plexus.Traverser from node to all adjacent nodes.

Specified by:
traverser in interface com.phoenixst.plexus.Graph

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).