V
- the graph vertex type.E
- the graph edge type.public class MaximumCardinalityIterator<V,E> extends AbstractGraphIterator<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.
crossComponentTraversal, graph, nListeners, reusableEdgeEvent, reusableVertexEvent, reuseEvents
Constructor and Description |
---|
MaximumCardinalityIterator(Graph<V,E> graph)
Creates a maximum cardinality iterator for the
graph . |
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Checks whether there exists unvisited vertex.
|
boolean |
isCrossComponentTraversal()
Test whether this iterator is set to traverse the graph across connected components.
|
V |
next()
Returns the next vertex in the ordering.
|
void |
setCrossComponentTraversal(boolean crossComponentTraversal)
Sets the cross component traversal flag - indicates whether to traverse the graph across
connected components.
|
addTraversalListener, createEdgeTraversalEvent, createVertexTraversalEvent, fireConnectedComponentFinished, fireConnectedComponentStarted, fireEdgeTraversed, fireVertexFinished, fireVertexTraversed, getGraph, isReuseEvents, remove, removeTraversalListener, setReuseEvents
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public boolean hasNext()
public V next()
public boolean isCrossComponentTraversal()
Always returns true since this iterator doesn't care about connected components.
isCrossComponentTraversal
in interface GraphIterator<V,E>
isCrossComponentTraversal
in class AbstractGraphIterator<V,E>
true
if traverses across connected components, otherwise
false
.public void setCrossComponentTraversal(boolean crossComponentTraversal)
Trying to disable the cross components nature of this iterator will result into throwing a
IllegalArgumentException
.
setCrossComponentTraversal
in class AbstractGraphIterator<V,E>
crossComponentTraversal
- if true
traverses across connected components.Copyright © 2019. All rights reserved.