bcds.phison
Class NodePairsTrig<V,E>

java.lang.Object
  extended by bcds.phison.NodePairsTrig<V,E>
All Implemented Interfaces:
java.lang.Iterable<SimplePair<V,V>>, java.util.Iterator<SimplePair<V,V>>

public class NodePairsTrig<V,E>
extends java.lang.Object
implements java.lang.Iterable<SimplePair<V,V>>, java.util.Iterator<SimplePair<V,V>>

Implements an iterator that produces node pairs of the "upper triangular" part of the full V * V matrix, excluding elements on the diagonal.

Only one of each possible pair is returned, i.e. (5, 9) but not (9, 5). Elements of the form (u, u) are never returned. Note that this has nothing to do with the graph's adjacency matrix (that is, its edges).

While the iterator is active, the underlying graph must not change. If it does, the behaviour is undefined.

Elements are returned in "order" so that all the pairs for row r are returned before proceeding to row (r+1).

Example of use with a for-each loop: for (SimplePair pr : new NodePairsTrig<V, E>(g) ) { ... do something with pr }

Author:
Juan Segovia S.

Constructor Summary
NodePairsTrig(SimGraph<V,E> g)
           
 
Method Summary
 boolean hasNext()
           
 java.util.Iterator<SimplePair<V,V>> iterator()
           
 SimplePair<V,V> next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodePairsTrig

public NodePairsTrig(SimGraph<V,E> g)
Method Detail

iterator

public java.util.Iterator<SimplePair<V,V>> iterator()
Specified by:
iterator in interface java.lang.Iterable<SimplePair<V,V>>

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<SimplePair<V,V>>

next

public SimplePair<V,V> next()
Specified by:
next in interface java.util.Iterator<SimplePair<V,V>>

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<SimplePair<V,V>>