public final class GraphUtils
extends java.lang.Object
GraphNodes).| Modifier and Type | Method and Description |
|---|---|
static <T extends GraphNode<T>,C extends java.util.Collection<T>> |
collectAllNodes(T node,
C collection)
Collects all nodes from the graph reachable from the given node in the given collection.
|
static <T extends GraphNode<T>> |
countAllDistinct(T node)
Counts all distinct nodes in the graph reachable from the given node.
|
static <T extends GraphNode<T>> |
getFirstChild(T node)
Returns the first child node of the given node or null if node is null or does not have any children.
|
static <T extends GraphNode<T>> |
getLastChild(T node)
Returns the last child node of the given node or null if node is null or does not have any children.
|
static boolean |
hasChildren(GraphNode<?> node)
Returns true if this node is not null and has at least one child node.
|
static <T extends GraphNode<T>> |
printTree(T node,
Formatter<T> formatter)
Creates a string representation of the graph reachable from the given node using the given formatter.
|
static <T extends GraphNode<T>> |
printTree(T node,
Formatter<T> formatter,
Predicate<T> nodeFilter,
Predicate<T> subTreeFilter)
Creates a string representation of the graph reachable from the given node using the given formatter.
|
public static boolean hasChildren(GraphNode<?> node)
node - a nodepublic static <T extends GraphNode<T>> T getFirstChild(T node)
node - a nodepublic static <T extends GraphNode<T>> T getLastChild(T node)
node - a nodepublic static <T extends GraphNode<T>> int countAllDistinct(T node)
node - the root nodepublic static <T extends GraphNode<T>,C extends java.util.Collection<T>> C collectAllNodes(T node, C collection)
node - the root nodecollection - the collection to collect intopublic static <T extends GraphNode<T>> java.lang.String printTree(T node, Formatter<T> formatter)
node - the root nodeformatter - the node formatterpublic static <T extends GraphNode<T>> java.lang.String printTree(T node, Formatter<T> formatter, Predicate<T> nodeFilter, Predicate<T> subTreeFilter)
node - the root nodeformatter - the node formatternodeFilter - the predicate selecting the nodes to printsubTreeFilter - the predicate determining whether to descend into a given nodes subtree or not