Class YutsisGraph

java.lang.Object
  |
  +--AbstractGraph
        |
        +--AbstractYutsis
              |
              +--YutsisGraph
All Implemented Interfaces:
java.lang.Cloneable, Graph, Yutsis

public class YutsisGraph
extends AbstractYutsis

Implementation of the abstract AbstractYutsis class representing a Yutsis graph in order to generate the summation formula in terms of 6j-coefficients for the general angular momentum recoupling coefficient (or 3nj-coefficents) represented by the couplings in this Yutsis graph. The main function of this class is an interactive text interface which allows the user to get information about the YutsisGraph and the reduction process.

Author:
Dries.VanDyck@rug.ac.be
See Also:
AbstractYutsis, NodeIterator, GenRecoupCoeff

Field Summary
 
Fields inherited from class AbstractYutsis
BRAKET, EDGELIST, YTS
 
Constructor Summary
YutsisGraph(java.io.BufferedReader input)
          Constructor creating a YutsisGraph from a BufferedReader in YTS format.
YutsisGraph(java.io.BufferedReader input, int format)
          Contructor creating a YutsisGraph from a BufferedReader in given format.
YutsisGraph(java.lang.String braket)
          Construcs a new YutsisGraph object from the braket in the String.
YutsisGraph(YutsisGraph y)
          Constructs an exact copy of this YutsisGraph.
 
Method Summary
 java.lang.String braket()
          Returns the braket notation of the original YutsisGraph.
 int[] bubble()
          Implementation of the abstract method Yutsis.bubble().
 java.lang.Object clone()
          Returns an exact copy of this YutsisGraph, as specified by the Cloneable interface.
 int cubicOrder()
          Return the original (cubic) order of this Cubic graph.
 java.lang.String[] edgeLabels(int node)
          Returns the labels of the edges coupled in the node node.
 Edge[] edges(int node)
          Returns (a copy) of the edges coupled in the node node.
 Edge[] edges(int[] nodes)
          Returns the edges between nodes[0] and nodes[1](max 3) as an array of edges.
 Edge[] edges(int node1, int node2)
          Returns the edges between node1 and node2 (max 3) as a Vector or null if one of the nodes is removed.
 NodeIterator first()
          Returns an NodeIterator over the nodeset starting at the node with lowest label as specified by the Graph interface.
 GenRecoupCoeff genRecoupCoeff()
          Returns the General Recoupling Coefficient corresponding with the current state of this YutsisGraph.
 java.lang.String[] gmlEdgeLabels(int i)
          Returns the edge label to be used for saving the Graph in GML-format; overloads AbstractGraph.gmlEdgeLabel.
static void interactive(YutsisGraph y)
          This function presents an interactive text interface allowing the user to get information about this YutsisGraph and the reduction process.
 void interchange(int[] nodes, int[] icnodes)
          Implementation of the abstract Yutsis.interchange(int [], int[] ) method.
 void invertEdge(int node, Edge e)
          Generates the phase factor (-1)^(2j), with j the label of the edge with endpoint node and inverts the edge afterwards.
 void invertSign(int node)
          Reverses the sign of node.
 boolean isNewLabel(java.lang.String label)
          True if this label did not appear in the original graph, if true this label will yield a summation over its complete domain.
 boolean isRemoved(int node)
          Implementation of the Graph.isRemoved(int) method.
 NodeIterator last()
          Returns an NodeIterator over the nodeset starting at the node with highest label in some ordening as specified by the Graph interface.
protected  void log(java.lang.String tolog)
          Write the String to the logstream.
static void main(java.lang.String[] args)
          This program constructs the YutsisGraph specified by the first argument and presents an interactive interface allowing the user to get information about the YutsisGraph and the reductionprocess.
 int n()
          Returns the (current) (cubic) order of this cubic graph.
 int[] neighbors(int node)
          Returns the neighbors of node or null if the node is removed from the graph as specified by the Graph interface.
 NodeIterator nodeIterator(int node)
          Returns an NodeIterator which will return node by a NodeIterator.next() call as specified by the Graph interface.
 int nrOfNodes()
          Returns the (current) number of nodes of this cubic graph as specified by the Graph interface.
 int order()
          Returns the original order (number or nodes) of this Graph as specified by the Graph interface.
 void removeBubble(int[] bubble)
          Implementation of the abstract Yutsis.removeBubble(int []) method.
 void removeTriangle(int[] triangle)
          Formats and removes the triangle triangle[0], triangle[1], triangle[2], as specified by the Yutsis interface.
 void setLogStream(java.io.PrintStream logstream)
          Sets the PrintStream to which all operation which alter the graph will be logged.
 boolean sign(int node)
          Returns the sign of node.
 java.lang.String toString()
          A String representation of this graph in it's current state.
 int[] triangle()
          Implementation of the abstract Yutsis.triangle() method.
 int[][] triangles()
          Implementation of the abstract Yutsis.triangles() method.
 boolean triangularDelta()
          Overrides the Yutsis.triangularDelta() method, taking in account node signs and edge directions.
 boolean triangularDelta(int[] td)
          Overrides the Yutsis.triangularDelta(int []) method, taking in account node signs and edge directions.
 boolean triangularDelta(int node1, int node2)
          Overrides the Yutsis.triangularDelta(int, int) method, taking in account node signs and edge directions.
 
Methods inherited from class AbstractYutsis
addIntermediateLabels, guessFileFormat, interchange, intermediateLabelsPresent, nrOfEdges, removeTriangle
 
Methods inherited from class AbstractGraph
addChangeListener, connected, fireStateChanged, isTree, removeChangeListener, toGml
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Graph
addChangeListener, connected, isTree, removeChangeListener, toGml
 

Constructor Detail

YutsisGraph

public YutsisGraph(java.io.BufferedReader input)
            throws java.io.IOException
Constructor creating a YutsisGraph from a BufferedReader in YTS format.

Parameters:
input - The BufferedReader where the YutsisGraph is read from.
Throws:
java.io.IOException - if an I/O error occurs

YutsisGraph

public YutsisGraph(java.io.BufferedReader input,
                   int format)
            throws java.io.IOException
Contructor creating a YutsisGraph from a BufferedReader in given format.

Parameters:
input - The BufferedReader where the YutsisGraph is read from.
format - The format used (BRAKET or YTS)
Throws:
java.io.IOException - if an I/O error occurs

YutsisGraph

public YutsisGraph(java.lang.String braket)
Construcs a new YutsisGraph object from the braket in the String.

Parameters:
braket - A string containing a Recoupling Coefficient as a BRAKET

YutsisGraph

public YutsisGraph(YutsisGraph y)
Constructs an exact copy of this YutsisGraph.

Parameters:
y - the YutsisGraph to be duplicated
Method Detail

order

public int order()
Returns the original order (number or nodes) of this Graph as specified by the Graph interface.

Returns:
the order of this Graph
See Also:
Graph

nrOfNodes

public int nrOfNodes()
Returns the (current) number of nodes of this cubic graph as specified by the Graph interface.

Returns:
the number of nodes of this Graph
See Also:
Graph

neighbors

public int[] neighbors(int node)
Returns the neighbors of node or null if the node is removed from the graph as specified by the Graph interface.

Parameters:
node - the node for wich the neighbors are returned
Returns:
the neighbors of the node as an array
See Also:
Graph

first

public NodeIterator first()
Returns an NodeIterator over the nodeset starting at the node with lowest label as specified by the Graph interface.

Returns:
a NodeIterator pointing to the first node
See Also:
NodeIterator, Graph

last

public NodeIterator last()
Returns an NodeIterator over the nodeset starting at the node with highest label in some ordening as specified by the Graph interface.

Returns:
a NodeIterator pointing to the last node
See Also:
NodeIterator, Graph

nodeIterator

public NodeIterator nodeIterator(int node)
Returns an NodeIterator which will return node by a NodeIterator.next() call as specified by the Graph interface.

Parameters:
node - the node to be returned by the first NodeIterator.next() of the returned NodeIterator
Returns:
a NodeIterator returning node by the first NodeIterator.next() call.
See Also:
NodeIterator, Graph

cubicOrder

public int cubicOrder()
Return the original (cubic) order of this Cubic graph. A graph having cubic order n has 2n nodes and 3n edges.

Returns:
the original cubic order of the graph

n

public int n()
Returns the (current) (cubic) order of this cubic graph. A graph having cubic order n has 2n nodes and 3n edges.

Returns:
the current cubic order of the graph

isRemoved

public boolean isRemoved(int node)
Implementation of the Graph.isRemoved(int) method.

Parameters:
node - the node to be checked
Returns:
true if the node is removed, false otherwise
See Also:
Graph

edges

public Edge[] edges(int node)
Returns (a copy) of the edges coupled in the node node.

Parameters:
node - the node of which edges will be returned
Returns:
an array of Edges containing a copy of the edges of the specified node

edgeLabels

public java.lang.String[] edgeLabels(int node)
Returns the labels of the edges coupled in the node node.

Parameters:
node - the node of which the labels of its Edges have to be returned
Returns:
the labels of the Edges coupled in the specified node

edges

public Edge[] edges(int[] nodes)
Returns the edges between nodes[0] and nodes[1](max 3) as an array of edges.

Parameters:
nodes - an array containg the nodes of which the Edges between them have to be returned
Returns:
the Edges connecting the specifed nodes as an array of Edges
See Also:
Edge

edges

public Edge[] edges(int node1,
                    int node2)
Returns the edges between node1 and node2 (max 3) as a Vector or null if one of the nodes is removed.

Parameters:
node1 - first node
node2 - second node
Returns:
the Edges between the specified nodes as an array of Edges
See Also:
Edge

sign

public boolean sign(int node)
Returns the sign of node.

Parameters:
node - the node of which the sign has to be returned
Returns:
true if the specified node is positive false otherwise

invertSign

public void invertSign(int node)
Reverses the sign of node.

Parameters:
node - the node of which the sign has to be inverted

invertEdge

public void invertEdge(int node,
                       Edge e)
Generates the phase factor (-1)^(2j), with j the label of the edge with endpoint node and inverts the edge afterwards.

Parameters:
node - an endpoint of the Edge to be inverted
See Also:
Edge

isNewLabel

public boolean isNewLabel(java.lang.String label)
True if this label did not appear in the original graph, if true this label will yield a summation over its complete domain.

Parameters:
label - the label which to be checked
Returns:
true if the label did not appear in the original YutsisGraph, false otherwise
See Also:
Edge

bubble

public int[] bubble()
Implementation of the abstract method Yutsis.bubble().

Returns:
the nodes of the bubble as an array or {-1,-1} if no bubbles are present
See Also:
Yutsis

removeBubble

public void removeBubble(int[] bubble)
Implementation of the abstract Yutsis.removeBubble(int []) method.

Parameters:
bubble - the bubble to be removed.
See Also:
Yutsis

triangle

public int[] triangle()
Implementation of the abstract Yutsis.triangle() method.

Returns:
the nodes of the triangle as an array or {-1,-1,-1} if no triangle are present.
See Also:
Yutsis

triangles

public int[][] triangles()
Implementation of the abstract Yutsis.triangles() method.

Returns:
all triangles as an array of int [3] objects.
See Also:
Yutsis

removeTriangle

public void removeTriangle(int[] triangle)
Formats and removes the triangle triangle[0], triangle[1], triangle[2], as specified by the Yutsis interface.

Parameters:
triangle - array containing the nodes of the triangle to be removed
See Also:
Yutsis

interchange

public void interchange(int[] nodes,
                        int[] icnodes)
Implementation of the abstract Yutsis.interchange(int [], int[] ) method.

Parameters:
nodes - array containing the endpoints of the Edge on which the interchange is performed
icnodes - array containing the neighbors of the corresponding nodes of nodes to be interchanged
See Also:
Yutsis

triangularDelta

public boolean triangularDelta()
Overrides the Yutsis.triangularDelta() method, taking in account node signs and edge directions.

Specified by:
triangularDelta in interface Yutsis
Overrides:
triangularDelta in class AbstractYutsis
Returns:
true if this graph can (and will) be formatted as a triangular delta
See Also:
Yutsis

triangularDelta

public boolean triangularDelta(int[] td)
Overrides the Yutsis.triangularDelta(int []) method, taking in account node signs and edge directions.

Specified by:
triangularDelta in interface Yutsis
Overrides:
triangularDelta in class AbstractYutsis
Parameters:
td - the nodes of the triangular delta as an array
Returns:
true if this YutsisGraph is a triangular delta between the specified nodes
See Also:
Yutsis

triangularDelta

public boolean triangularDelta(int node1,
                               int node2)
Overrides the Yutsis.triangularDelta(int, int) method, taking in account node signs and edge directions.

Specified by:
triangularDelta in interface Yutsis
Overrides:
triangularDelta in class AbstractYutsis
Parameters:
node1 - first node of the triangular delta to be formatted
node2 - second node of the triangular delta to be formatted
Returns:
true if this YutsisGraph is a triangular delta between the specified nodes
See Also:
Yutsis

genRecoupCoeff

public GenRecoupCoeff genRecoupCoeff()
Returns the General Recoupling Coefficient corresponding with the current state of this YutsisGraph.

Returns:
the GenRecoupCoeff
See Also:
GenRecoupCoeff

log

protected void log(java.lang.String tolog)
Write the String to the logstream.

Parameters:
tolog - the String to be logged

braket

public java.lang.String braket()
Returns the braket notation of the original YutsisGraph.

Returns:
the braket notation of the original YutsisGraph

setLogStream

public void setLogStream(java.io.PrintStream logstream)
Sets the PrintStream to which all operation which alter the graph will be logged. Default logstream is System.err. When no logging is desired, set it to be null.

Parameters:
logstream - The PrintStream where logging will be done

toString

public java.lang.String toString()
A String representation of this graph in it's current state. Format: n
...
node | edgelabel1: nghb1 edgelabel2: nghb2 edgelabel3: nghb3
... .

Overrides:
toString in class AbstractGraph
Returns:
a String representation of this YutsisGraph.

gmlEdgeLabels

public java.lang.String[] gmlEdgeLabels(int i)
Returns the edge label to be used for saving the Graph in GML-format; overloads AbstractGraph.gmlEdgeLabel.

Overrides:
gmlEdgeLabels in class AbstractGraph
Parameters:
i - first node of the edge
Returns:
a label for the edge (i,j) or null if no label is desired.

clone

public java.lang.Object clone()
Returns an exact copy of this YutsisGraph, as specified by the Cloneable interface.

Specified by:
clone in interface Yutsis
Overrides:
clone in class AbstractGraph
Returns:
a clone of this YutsisGraph.

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
This program constructs the YutsisGraph specified by the first argument and presents an interactive interface allowing the user to get information about the YutsisGraph and the reductionprocess. When ran without arguments it prints a "usage" to System.err.

java.io.IOException

interactive

public static void interactive(YutsisGraph y)
                        throws java.io.IOException
This function presents an interactive text interface allowing the user to get information about this YutsisGraph and the reduction process. Uses CycleCostAlgorithm. CycleGenerator, PathGenerator..

Parameters:
y - the intial YutsisGraph
Throws:
java.io.IOException - if an I/O error occurs