Class Graph

java.lang.Object
net.minecraft.util.Graph

public final class Graph extends Object
  • Constructor Details

    • Graph

      private Graph()
  • Method Details

    • depthFirstSearch

      public static <T> boolean depthFirstSearch(Map<T,Set<T>> edges, Set<T> discovered, Set<T> currentlyVisiting, Consumer<T> reverseTopologicalOrder, T current)
      Detects if a cycle is present in the given graph, via a depth first search, and returns true if a cycle was found.
      Parameters:
      discovered - Nodes that are verified to have no cycles involving them.
      currentlyVisiting - The current collection of seen nodes. When invoked not recursively, this should be an empty set.
      reverseTopologicalOrder - Invoked on each node as we prove that no cycles can be reached starting from this node.