- Type Parameters:
- V- the graph vertex type.
- E- the graph edge type.
- All Implemented Interfaces:
- Iterator<V>,- GraphIterator<V,- E> 
For every vertex in graph its cardinality is defined as the number of its neighbours, which have been already visited by this iterator. Iterator chooses vertex with the maximum cardinality, breaking ties arbitrarily. For more information of maximum cardinality search see: Berry, A., Blair, J., Heggernes, P. et al. Algorithmica (2004) 39: 287. https://doi.org/10.1007/s00453-004-1084-3 Maximum Cardinality Search for Computing Minimal Triangulations.
For this iterator to work correctly the graph must not be modified during iteration. Currently there are no means to ensure that, nor to fail-fast. The results of such modifications are undefined.
Note: only vertex events are fired by this iterator.
- Author:
- Timofey Chudakov
- 
Field SummaryFields inherited from class org.jgrapht.traverse.AbstractGraphIteratorcrossComponentTraversal, graph, nListeners, reusableEdgeEvent, reusableVertexEvent, reuseEvents
- 
Constructor SummaryConstructorsConstructorDescriptionMaximumCardinalityIterator(Graph<V, E> graph) Creates a maximum cardinality iterator for thegraph.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanhasNext()Checks whether there exists unvisited vertex.booleanTest whether this iterator is set to traverse the graph across connected components.next()Returns the next vertex in the ordering.voidsetCrossComponentTraversal(boolean crossComponentTraversal) Sets the cross component traversal flag - indicates whether to traverse the graph across connected components.Methods inherited from class org.jgrapht.traverse.AbstractGraphIteratoraddTraversalListener, createEdgeTraversalEvent, createVertexTraversalEvent, fireConnectedComponentFinished, fireConnectedComponentStarted, fireEdgeTraversed, fireVertexFinished, fireVertexTraversed, getGraph, isReuseEvents, remove, removeTraversalListener, setReuseEventsMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.IteratorforEachRemaining
- 
Constructor Details- 
MaximumCardinalityIteratorCreates a maximum cardinality iterator for thegraph.- Parameters:
- graph- the graph to be iterated.
 
 
- 
- 
Method Details- 
hasNextpublic boolean hasNext()Checks whether there exists unvisited vertex.- Returns:
- true if there exists unvisited vertex.
 
- 
nextReturns the next vertex in the ordering.- Returns:
- the next vertex in the ordering.
 
- 
isCrossComponentTraversalpublic boolean isCrossComponentTraversal()Test whether this iterator is set to traverse the graph across connected components.Always returns true since this iterator doesn't care about connected components. - Specified by:
- isCrossComponentTraversalin interface- GraphIterator<V,- E> 
- Overrides:
- isCrossComponentTraversalin class- AbstractGraphIterator<V,- E> 
- Returns:
- trueif traverses across connected components, otherwise- false.
 
- 
setCrossComponentTraversalpublic void setCrossComponentTraversal(boolean crossComponentTraversal) Sets the cross component traversal flag - indicates whether to traverse the graph across connected components.Trying to disable the cross components nature of this iterator will result into throwing a IllegalArgumentException.- Overrides:
- setCrossComponentTraversalin class- AbstractGraphIterator<V,- E> 
- Parameters:
- crossComponentTraversal- if- truetraverses across connected components.
 
 
-