use of org.neo4j.graphalgo.impl.path.ExactDepthPathFinder in project neo4j by neo4j.
the class TestExactDepthPathFinder method shouldHandleDirectionalGraph.
@Test
public void shouldHandleDirectionalGraph() {
// ALL DIRECTED from (a) towards (g)
// (b) ----------------- (c) length 3
// / \
// (a) - (h) - (i) - (j) - (k) - (g) length 5
// \ /
// (d) - (e) ------------ (f) length 4
graph.makeEdgeChain("a,b,c,g");
graph.makeEdgeChain("a,d,e,f,g");
graph.makeEdgeChain("a,h,i,j,k,g");
Node a = graph.getNode("a");
Node g = graph.getNode("g");
assertPaths(new ExactDepthPathFinder(PathExpanders.forDirection(Direction.OUTGOING), 3, Integer.MAX_VALUE, false).findAllPaths(a, g), "a,b,c,g");
assertPaths(new ExactDepthPathFinder(PathExpanders.forDirection(Direction.OUTGOING), 4, Integer.MAX_VALUE, false).findAllPaths(a, g), "a,d,e,f,g");
assertPaths(new ExactDepthPathFinder(PathExpanders.forDirection(Direction.OUTGOING), 5, Integer.MAX_VALUE, false).findAllPaths(a, g), "a,h,i,j,k,g");
}
use of org.neo4j.graphalgo.impl.path.ExactDepthPathFinder in project neo4j by neo4j.
the class TestExactDepthPathFinder method shouldHandleSimpleChainEvenDepth.
@Test
public void shouldHandleSimpleChainEvenDepth() {
// (a) - (b) - (c)
graph.makeEdgeChain("a,b,c");
Node a = graph.getNode("a");
Node c = graph.getNode("c");
assertPaths(new ExactDepthPathFinder(PathExpanders.allTypesAndDirections(), 2, Integer.MAX_VALUE, false).findAllPaths(a, c), "a,b,c");
assertPaths(new ExactDepthPathFinder(PathExpanders.allTypesAndDirections(), 2, Integer.MAX_VALUE, false).findAllPaths(a, c), "a,b,c");
}
use of org.neo4j.graphalgo.impl.path.ExactDepthPathFinder in project neo4j by neo4j.
the class TestExactDepthPathFinder method shouldHandleNondirectedGraph.
@Test
public void shouldHandleNondirectedGraph() {
// (b) ----------------- (c) length 3
// / \
// (a) - (h) - (i) - (j) - (k) - (g) length 5
// \ /
// (d) - (e) ------------ (f) length 4
graph.makeEdgeChain("a,b,c,g");
graph.makeEdgeChain("a,d,e,f,g");
graph.makeEdgeChain("a,h,i,j,k,g");
Node a = graph.getNode("a");
Node g = graph.getNode("g");
assertPaths(new ExactDepthPathFinder(PathExpanders.allTypesAndDirections(), 3, Integer.MAX_VALUE, false).findAllPaths(a, g), "a,b,c,g");
assertPaths(new ExactDepthPathFinder(PathExpanders.allTypesAndDirections(), 4, Integer.MAX_VALUE, false).findAllPaths(a, g), "a,d,e,f,g");
assertPaths(new ExactDepthPathFinder(PathExpanders.allTypesAndDirections(), 5, Integer.MAX_VALUE, false).findAllPaths(a, g), "a,h,i,j,k,g");
}
use of org.neo4j.graphalgo.impl.path.ExactDepthPathFinder in project neo4j by neo4j.
the class TestExactDepthPathFinder method shouldHandleNeighbouringNodes.
@Test
public void shouldHandleNeighbouringNodes() {
// (a) - (b)
graph.makeEdgeChain("a,b");
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");
}
use of org.neo4j.graphalgo.impl.path.ExactDepthPathFinder in project neo4j by neo4j.
the class TestExactDepthPathFinder method shouldHandleNeighbouringNodesMultiplePaths.
@Test
public void shouldHandleNeighbouringNodesMultiplePaths() {
// (a) = (b)
// |
// (c)
graph.makeEdgeChain("a,b");
graph.makeEdgeChain("a,b");
graph.makeEdgeChain("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", "a,b");
assertPaths(new ExactDepthPathFinder(PathExpanders.allTypesAndDirections(), 1, Integer.MAX_VALUE, false).findAllPaths(a, b), "a,b", "a,b");
}
Aggregations