Search in sources :

Example 41 with Direction

use of org.neo4j.graphdb.Direction in project neo4j by neo4j.

the class TestLoopRelationships method verifyRelationships.

private void verifyRelationships(String message, Node root, boolean[] loop, Relationship... relationships) {
    for (Direction dir : Direction.values()) {
        Set<Relationship> expected = new HashSet<Relationship>();
        for (int i = 0; i < relationships.length; i++) {
            if (relationships[i] != null && (dir != Direction.INCOMING || loop[i])) {
                expected.add(relationships[i]);
            }
        }
        for (Relationship rel : root.getRelationships(dir)) {
            assertTrue(message + ": unexpected relationship: " + rel, expected.remove(rel));
        }
        assertTrue(message + ": expected relationships not seen " + expected, expected.isEmpty());
    }
}
Also used : Relationship(org.neo4j.graphdb.Relationship) Direction(org.neo4j.graphdb.Direction) HashSet(java.util.HashSet)

Example 42 with Direction

use of org.neo4j.graphdb.Direction in project jo-client-platform by jo-source.

the class SyncNeo4JSimpleRelatedReaderServiceImpl method getAllRelatedNodes.

private List<Tuple<Node, Relationship>> getAllRelatedNodes(final List<Tuple<Node, Relationship>> parentNodes, final Tuple<RelationshipType, Direction> relation, final IExecutionCallback executionCallback) {
    final List<Tuple<Node, Relationship>> result = new LinkedList<Tuple<Node, Relationship>>();
    final RelationshipType relationshipType = relation.getFirst();
    final Direction direction = relation.getSecond();
    for (final Tuple<Node, Relationship> parentNodeTuple : parentNodes) {
        CapServiceToolkit.checkCanceled(executionCallback);
        final Node parentNode = parentNodeTuple.getFirst();
        for (final Relationship relationship : parentNode.getRelationships(direction, relationshipType)) {
            CapServiceToolkit.checkCanceled(executionCallback);
            result.add(new Tuple<Node, Relationship>(relationship.getOtherNode(parentNode), relationship));
        }
    }
    return result;
}
Also used : Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) RelationshipType(org.neo4j.graphdb.RelationshipType) Direction(org.neo4j.graphdb.Direction) Tuple(org.jowidgets.util.Tuple) LinkedList(java.util.LinkedList)

Aggregations

Direction (org.neo4j.graphdb.Direction)42 Relationship (org.neo4j.graphdb.Relationship)25 Test (org.junit.Test)21 RelationshipType (org.neo4j.graphdb.RelationshipType)14 Node (org.neo4j.graphdb.Node)11 EigenvectorCentrality (org.neo4j.graphalgo.impl.centrality.EigenvectorCentrality)10 HashMap (java.util.HashMap)6 Dijkstra (org.neo4j.graphalgo.impl.shortestpath.Dijkstra)6 Collection (java.util.Collection)4 HashSet (java.util.HashSet)4 List (java.util.List)4 DoubleAdder (org.neo4j.graphalgo.impl.util.DoubleAdder)4 DoubleComparator (org.neo4j.graphalgo.impl.util.DoubleComparator)4 EnumMap (java.util.EnumMap)3 PropertyContainer (org.neo4j.graphdb.PropertyContainer)3 NestingIterator (org.neo4j.helpers.collection.NestingIterator)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Stack (java.util.Stack)2 TreeMap (java.util.TreeMap)2