Search in sources :

Example 6 with ExactDepthPathFinder

use of org.neo4j.graphalgo.impl.path.ExactDepthPathFinder in project neo4j by neo4j.

the class TestExactDepthPathFinder method shouldHandleNeighbouringNodesWhenNotAlone.

@Test
public void shouldHandleNeighbouringNodesWhenNotAlone() {
    // (a) - (b)
    //  |
    // (c)
    graph.makeEdge("a", "b");
    graph.makeEdge("a", "c");
    Node a = graph.getNode("a");
    Node b = graph.getNode("b");
    ExactDepthPathFinder pathFinder = new ExactDepthPathFinder(PathExpanders.allTypesAndDirections(), 1, Integer.MAX_VALUE, false);
    Iterable<Path> allPaths = pathFinder.findAllPaths(a, b);
    assertPaths(new ExactDepthPathFinder(PathExpanders.allTypesAndDirections(), 1, Integer.MAX_VALUE, false).findAllPaths(a, b), "a,b");
    assertPaths(new ExactDepthPathFinder(PathExpanders.allTypesAndDirections(), 1, Integer.MAX_VALUE, false).findAllPaths(a, b), "a,b");
}
Also used : Path(org.neo4j.graphdb.Path) Node(org.neo4j.graphdb.Node) ExactDepthPathFinder(org.neo4j.graphalgo.impl.path.ExactDepthPathFinder) Test(org.junit.Test)

Example 7 with ExactDepthPathFinder

use of org.neo4j.graphalgo.impl.path.ExactDepthPathFinder in project neo4j by neo4j.

the class TestExactDepthPathFinder method shouldHandleSimpleChainOddDepth.

@Test
public void shouldHandleSimpleChainOddDepth() {
    // (a) - (b) - (c) - (d)
    graph.makeEdgeChain("a,b,c,d");
    Node a = graph.getNode("a");
    Node d = graph.getNode("d");
    assertPaths(new ExactDepthPathFinder(PathExpanders.allTypesAndDirections(), 3, Integer.MAX_VALUE, false).findAllPaths(a, d), "a,b,c,d");
    assertPaths(new ExactDepthPathFinder(PathExpanders.allTypesAndDirections(), 3, Integer.MAX_VALUE, false).findAllPaths(a, d), "a,b,c,d");
}
Also used : Node(org.neo4j.graphdb.Node) ExactDepthPathFinder(org.neo4j.graphalgo.impl.path.ExactDepthPathFinder) Test(org.junit.Test)

Example 8 with ExactDepthPathFinder

use of org.neo4j.graphalgo.impl.path.ExactDepthPathFinder in project neo4j by neo4j.

the class TestExactDepthPathFinder method testExactDepthPathsLoopsAllowed.

@Test
public void testExactDepthPathsLoopsAllowed() {
    // Layout:
    //
    // (a)-->(b)==>(c)-->(e)
    //        ^    /
    //         \  v
    //         (d)
    //
    graph.makeEdgeChain("a,b,c,d,b,c,e");
    Node a = graph.getNode("a");
    Node e = graph.getNode("e");
    assertPaths(new ExactDepthPathFinder(PathExpanders.forDirection(Direction.OUTGOING), 6, Integer.MAX_VALUE, true).findAllPaths(a, e), "a,b,c,d,b,c,e");
}
Also used : Node(org.neo4j.graphdb.Node) ExactDepthPathFinder(org.neo4j.graphalgo.impl.path.ExactDepthPathFinder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 ExactDepthPathFinder (org.neo4j.graphalgo.impl.path.ExactDepthPathFinder)8 Node (org.neo4j.graphdb.Node)8 Path (org.neo4j.graphdb.Path)3