|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.parboiled.trees.GraphUtils
public final class GraphUtils
General utility methods for operating on directed graphs (consisting of GraphNodes).
| Method Summary | ||
|---|---|---|
static
|
collectAllNodes(T node,
C collection)
Collects all nodes from the graph reachable from the given node in the given collection. |
|
static
|
countAllDistinct(T node)
Counts all distinct nodes in the graph reachable from the given node. |
|
static
|
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
|
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
|
printTree(T node,
Formatter<T> formatter)
Creates a string representation of the graph reachable from the given node using the given formatter. |
|
static
|
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. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean hasChildren(GraphNode<?> node)
node - a node
public static <T extends GraphNode<T>> T getFirstChild(T node)
node - a node
public static <T extends GraphNode<T>> T getLastChild(T node)
node - a node
public static <T extends GraphNode<T>> int countAllDistinct(T node)
node - the root node
public 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 into
public static <T extends GraphNode<T>> java.lang.String printTree(T node,
Formatter<T> formatter)
node - the root nodeformatter - the node formatter
public 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
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||