Search in sources :

Example 1 with NodeGraph

use of jcog.data.graph.NodeGraph in project narchy by automenta.

the class NodeGraphTest method testDFS.

@Test
public void testDFS() {
    NodeGraph n = g1();
    List<String> trace = new FasterList();
    n.dfs("a", new Search() {

        @Override
        protected boolean next(BooleanObjectPair move, NodeGraph.Node next) {
            trace.add(path.toString());
            return true;
        }
    });
    assertEquals(4, trace.size());
    assertEquals("[[true:a => ab => b], [true:a => ab => b, true:b => bc => c], [true:a => ab => b, true:b => bc => c, true:c => cd => d], [true:a => ae => e]]", trace.toString());
}
Also used : FasterList(jcog.list.FasterList) BooleanObjectPair(org.eclipse.collections.api.tuple.primitive.BooleanObjectPair) NodeGraph(jcog.data.graph.NodeGraph) MapNodeGraph(jcog.data.graph.MapNodeGraph) Test(org.junit.jupiter.api.Test)

Example 2 with NodeGraph

use of jcog.data.graph.NodeGraph in project narchy by automenta.

the class NodeGraphTest method testBFS.

@Test
public void testBFS() {
    NodeGraph n = g1();
    List<String> trace = new FasterList();
    n.bfs("a", new Search() {

        @Override
        protected boolean next(BooleanObjectPair move, NodeGraph.Node next) {
            trace.add(path.toString());
            return true;
        }
    });
    assertEquals(4, trace.size());
    assertEquals("[[true:a => ab => b], [true:a => ae => e], [true:a => ab => b, true:b => bc => c], [true:a => ab => b, true:b => bc => c, true:c => cd => d]]", trace.toString());
}
Also used : FasterList(jcog.list.FasterList) BooleanObjectPair(org.eclipse.collections.api.tuple.primitive.BooleanObjectPair) NodeGraph(jcog.data.graph.NodeGraph) MapNodeGraph(jcog.data.graph.MapNodeGraph) Test(org.junit.jupiter.api.Test)

Aggregations

MapNodeGraph (jcog.data.graph.MapNodeGraph)2 NodeGraph (jcog.data.graph.NodeGraph)2 FasterList (jcog.list.FasterList)2 BooleanObjectPair (org.eclipse.collections.api.tuple.primitive.BooleanObjectPair)2 Test (org.junit.jupiter.api.Test)2