use of org.neo4j.graphdb.Path 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.graphdb.Path 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");
}
use of org.neo4j.graphdb.Path in project neo4j by neo4j.
the class Neo4jAlgoTestCase method assertPathsWithPaths.
public void assertPathsWithPaths(Iterable<? extends Path> actualPaths, Path... expectedPaths) {
List<String> pathDefs = new ArrayList<>();
for (Path path : expectedPaths) {
pathDefs.add(getPathDef(path));
}
assertPaths(actualPaths, pathDefs);
}
use of org.neo4j.graphdb.Path in project neo4j by neo4j.
the class PathImplTest method pathsWithTheSameContentsShouldBeEqual.
@Test
public void pathsWithTheSameContentsShouldBeEqual() throws Exception {
Node node = createNode(1337L);
Relationship relationship = createRelationship(1337L, 7331L);
// Given
Path firstPath = new PathImpl.Builder(node).push(relationship).build();
Path secondPath = new PathImpl.Builder(node).push(relationship).build();
// When Then
assertEquals(firstPath, secondPath);
assertEquals(secondPath, firstPath);
}
use of org.neo4j.graphdb.Path in project neo4j by neo4j.
the class PathImplTest method testPathReverseNodes.
@Test
public void testPathReverseNodes() {
when(relationshipActions.newNodeProxy(Mockito.anyLong())).thenAnswer(new NodeProxyAnswer());
Path path = new PathImpl.Builder(createNodeProxy(1)).push(createRelationshipProxy(1, 2)).push(createRelationshipProxy(2, 3)).build(new PathImpl.Builder(createNodeProxy(3)));
Iterable<Node> nodes = path.reverseNodes();
List<Node> nodeList = Iterables.asList(nodes);
Assert.assertEquals(3, nodeList.size());
Assert.assertEquals(3, nodeList.get(0).getId());
Assert.assertEquals(2, nodeList.get(1).getId());
Assert.assertEquals(1, nodeList.get(2).getId());
}
Aggregations