Class DegeneracyOrderingIterator<V,E>

java.lang.Object
org.jgrapht.traverse.AbstractGraphIterator<V,E>
org.jgrapht.traverse.DegeneracyOrderingIterator<V,E>
Type Parameters:
V - the graph vertex type
E - 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
  • Constructor Details

    • DegeneracyOrderingIterator

      public DegeneracyOrderingIterator(Graph<V,E> graph)
      Constructor
      Parameters:
      graph - the graph to be iterated
  • Method Details

    • 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 interface GraphIterator<V,E>
      Overrides:
      isCrossComponentTraversal in class AbstractGraphIterator<V,E>
      Returns:
      true if traverses across connected components, otherwise false.
    • setCrossComponentTraversal

      public 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:
      setCrossComponentTraversal in class AbstractGraphIterator<V,E>
      Parameters:
      crossComponentTraversal - if true traverses across connected components.
    • hasNext

      public boolean hasNext()
    • next

      public V next()