- java.lang.Object
-
- org.jgrapht.traverse.AbstractGraphIterator<V,E>
-
- org.jgrapht.traverse.DegeneracyOrderingIterator<V,E>
-
- Type Parameters:
V
- the graph vertex typeE
- the graph edge type
- All Implemented Interfaces:
Iterator<V>
,GraphIterator<V,E>
public class DegeneracyOrderingIterator<V,E> extends AbstractGraphIterator<V,E>
A degeneracy ordering iterator.The degeneracy of a graph $G $is the smallest value d such that every nonempty subgraph of $G$ contains a vertex of degree at most $d.$ If a graph has degeneracy $d$, then it has a degeneracy ordering, an ordering such that each vertex has $d$ or fewer neighbors that come later in the ordering.
The iterator crosses components but does not track them, it only tracks visited vertices.
The iterator treats the input graph as undirected even if the graph is directed. Moreover, it completely ignores self-loops, meaning that it operates as if self-loops do not contribute to the degree of a vertex.
- Author:
- Dimitrios Michail
-
-
Field Summary
-
Fields inherited from class org.jgrapht.traverse.AbstractGraphIterator
crossComponentTraversal, graph, nListeners, reusableEdgeEvent, reusableVertexEvent, reuseEvents
-
-
Constructor Summary
Constructors Constructor Description DegeneracyOrderingIterator(Graph<V,E> graph)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
boolean
isCrossComponentTraversal()
Test whether this iterator is set to traverse the graph across connected components.V
next()
void
setCrossComponentTraversal(boolean crossComponentTraversal)
Sets the cross component traversal flag - indicates whether to traverse the graph across connected components.-
Methods inherited from class org.jgrapht.traverse.AbstractGraphIterator
addTraversalListener, createEdgeTraversalEvent, createVertexTraversalEvent, fireConnectedComponentFinished, fireConnectedComponentStarted, fireEdgeTraversed, fireVertexFinished, fireVertexTraversed, getGraph, isReuseEvents, remove, removeTraversalListener, setReuseEvents
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
DegeneracyOrderingIterator
public DegeneracyOrderingIterator(Graph<V,E> graph)
Constructor- Parameters:
graph
- the graph to be iterated- Throws:
NullPointerException
- if argument isnull
-
-
Method Detail
-
isCrossComponentTraversal
public boolean isCrossComponentTraversal()
Test whether this iterator is set to traverse the graph across connected components. Always returns true since the iterator does not care about components.- Specified by:
isCrossComponentTraversal
in interfaceGraphIterator<V,E>
- Overrides:
isCrossComponentTraversal
in classAbstractGraphIterator<V,E>
- Returns:
true
if traverses across connected components, otherwisefalse
.
-
setCrossComponentTraversal
public void setCrossComponentTraversal(boolean crossComponentTraversal)
Description copied from class:AbstractGraphIterator
Sets the cross component traversal flag - indicates whether to traverse the graph across connected components.- Overrides:
setCrossComponentTraversal
in classAbstractGraphIterator<V,E>
- Parameters:
crossComponentTraversal
- iftrue
traverses across connected components.- Throws:
IllegalArgumentException
- if disabling the cross components nature of this iterator is attempted
-
hasNext
public boolean hasNext()
-
next
public V next()
-
-