Rooted Tree Tester

Download

Download jar file or use maven. psjava requires Java 1.6 (or above)

<dependency>
    <groupId>org.psjava</groupId>
    <artifactId>psjava</artifactId>
    <version>0.1.19</version>
</dependency>

Example Code

MutableDirectedUnweightedGraph<String> tree = MutableDirectedUnweightedGraph.create();
tree.insertVertex("A");
tree.insertVertex("B");
tree.insertVertex("C");

tree.addEdge("A", "B");
tree.addEdge("A", "C");

boolean result1 = RootedTreeTester.is(tree, "A"); // must be true

MutableDirectedUnweightedGraph<String> cycled = MutableDirectedUnweightedGraph.create();
cycled.insertVertex("A");
cycled.insertVertex("B");

cycled.addEdge("A", "B");
cycled.addEdge("B", "A");

boolean result2 = RootedTreeTester.is(cycled, "A"); // must be false

See Also

Implementation


Copyright 2014 psjava team. View on GitHub