Search in sources :

Example 51 with BasicEvaluationContext

use of org.neo4j.graphalgo.BasicEvaluationContext in project neo4j by neo4j.

the class TestExactDepthPathFinder method testExactDepthPathsLoopsAllowed.

@Test
void testExactDepthPathsLoopsAllowed() {
    // 
    try (Transaction transaction = graphDb.beginTx()) {
        graph.makeEdgeChain(transaction, "a,b,c,d,b,c,e");
        Node a = graph.getNode(transaction, "a");
        Node e = graph.getNode(transaction, "e");
        var context = new BasicEvaluationContext(transaction, graphDb);
        assertPaths(new ExactDepthPathFinder(context, forDirection(Direction.OUTGOING), 6, Integer.MAX_VALUE, true).findAllPaths(a, e), "a,b,c,d,b,c,e");
        transaction.commit();
    }
}
Also used : BasicEvaluationContext(org.neo4j.graphalgo.BasicEvaluationContext) Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) ExactDepthPathFinder(org.neo4j.graphalgo.impl.path.ExactDepthPathFinder) Test(org.junit.jupiter.api.Test)

Example 52 with BasicEvaluationContext

use of org.neo4j.graphalgo.BasicEvaluationContext in project neo4j by neo4j.

the class TestShortestPath method testDirectedFinder.

@Test
void testDirectedFinder() {
    // 
    try (Transaction transaction = graphDb.beginTx()) {
        graph.makeEdgeChain(transaction, "a,b,c,d,e,f,m");
        graph.makeEdgeChain(transaction, "a,g,h,i,j,k,l,m");
        var context = new BasicEvaluationContext(transaction, graphDb);
        testShortestPathFinder(context, finder -> assertPaths(finder.findAllPaths(graph.getNode(transaction, "a"), graph.getNode(transaction, "j")), "a,g,h,i,j"), forTypeAndDirection(R1, OUTGOING), 4);
        transaction.commit();
    }
}
Also used : BasicEvaluationContext(org.neo4j.graphalgo.BasicEvaluationContext) Transaction(org.neo4j.graphdb.Transaction) Test(org.junit.jupiter.api.Test)

Aggregations

BasicEvaluationContext (org.neo4j.graphalgo.BasicEvaluationContext)52 Transaction (org.neo4j.graphdb.Transaction)52 Node (org.neo4j.graphdb.Node)40 Test (org.junit.jupiter.api.Test)33 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 MethodSource (org.junit.jupiter.params.provider.MethodSource)20 WeightedPath (org.neo4j.graphalgo.WeightedPath)20 Path (org.neo4j.graphdb.Path)18 ExactDepthPathFinder (org.neo4j.graphalgo.impl.path.ExactDepthPathFinder)8 Relationship (org.neo4j.graphdb.Relationship)8 HashSet (java.util.HashSet)5 PathExpander (org.neo4j.graphdb.PathExpander)5 GraphAlgoFactory.shortestPath (org.neo4j.graphalgo.GraphAlgoFactory.shortestPath)4 Neo4jAlgoTestCase (common.Neo4jAlgoTestCase)3 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)3 EvaluationContext (org.neo4j.graphalgo.EvaluationContext)3 PathFinder (org.neo4j.graphalgo.PathFinder)3 OUTGOING (org.neo4j.graphdb.Direction.OUTGOING)3 Label (org.neo4j.graphdb.Label)3 PathExpanders.allTypesAndDirections (org.neo4j.graphdb.PathExpanders.allTypesAndDirections)3