Class 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 Detail

      • DegeneracyOrderingIterator

        public DegeneracyOrderingIterator​(Graph<V,​E> graph)
        Constructor
        Parameters:
        graph - the graph to be iterated
        Throws:
        NullPointerException - if argument is null
    • 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 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)
        Description copied from class: AbstractGraphIterator
        Sets the cross component traversal flag - indicates whether to traverse the graph across connected components.
        Overrides:
        setCrossComponentTraversal in class AbstractGraphIterator<V,​E>
        Parameters:
        crossComponentTraversal - if true 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()