Package org.neo4j.graphdb

Examples of org.neo4j.graphdb.Path


            {
                return indexedRelationshipIterator.next();
            }
            if ( indexedRelationshipDestinationIterator != null && indexedRelationshipDestinationIterator.hasNext() )
            {
                Path path = indexedRelationshipDestinationIterator.next();
                String direction = (String) path.lastRelationship().getProperty(
                    IndexedRelationship.RELATIONSHIP_DIRECTION );
                try
                {
                    IndexedRelationship indexedRelationship = new IndexedRelationship( path.endNode(), relType,
                        Direction.valueOf( direction ) );
                    return indexedRelationship.getRelationship( path.relationships().iterator().next() );
                }
                catch ( Exception e )
                {
                    throw new RuntimeException( "Comparator class cannot be instantiated" );
                }
View Full Code Here


                OsmRelation.BIDIRECTIONAL, Direction.BOTH);


        PathFinder<WeightedPath> finder = GraphAlgoFactory.aStar(relExpander, costEval, estimateEval);

        Path route = finder.findSinglePath(startNode, endNode);
        return getPathGeometries(route.relationships());
    }
View Full Code Here

        assertNull("no result",result);
        assertEquals(PATHS_COUNT, counter.get());
    }

    private List<Path> paths() {
        Path anyPath = mock(Path.class);
        Path[] paths=new Path[3];
        Arrays.fill(paths,anyPath);
        return Arrays.asList(paths);
    }
View Full Code Here

    public List<?> getBaconPath(final Actor actor) {
        if (actor == null) throw new IllegalArgumentException("Null actor");

        Actor bacon = actorRepository.findByPropertyValue("name", "Bacon, Kevin");

        Path path = GraphAlgoFactory.shortestPath((PathExpander)StandardExpander.DEFAULT.add(RelTypes.ACTS_IN), 10).findSinglePath(bacon.getPersistentState(), actor.getPersistentState());
        if (path==null) return Collections.emptyList();
        return convertNodesToActorsAndMovies(path);
    }
View Full Code Here

        String uri = "http://localhost:7470";
        RestAPI restApi = new RestAPIImpl(uri);
        Map<String,Object> node = MapUtil.map("data", Collections.EMPTY_MAP, "self", uri + "/db/data/node/0");
        Map<String, Object> pathData = MapUtil.map("start", node, "nodes",Collections.singletonList(node),"length", 0, "relationships", Collections.EMPTY_LIST, "end", node);
        System.out.println("pathData = " + pathData);
        Path path = RestPathParser.parse(pathData, restApi);
        assertEquals(0,path.length());
        assertEquals(null,path.lastRelationship());
        assertEquals(0,path.startNode().getId());
        assertEquals(0,path.endNode().getId());
    }
View Full Code Here

        Map<String,Object> node = node(0);
        Map<String,Object> node2 = node(1);
        Map<String,Object> relationship = relationship(1,0,1);
        Map<String, Object> pathData = MapUtil.map("start", node, "nodes", Arrays.asList(node, node2),"length", 1, "relationships", Collections.singletonList(relationship), "end", node2);
        System.out.println("pathData = " + pathData);
        Path path = RestPathParser.parse(pathData, restApi);
        assertEquals(1,path.length());
        assertEquals(1,path.lastRelationship().getId());
        assertEquals(0,path.startNode().getId());
        assertEquals(1,path.endNode().getId());
    }
View Full Code Here

        path.put("start", node1);
        path.put("nodes", asList(node1, node2));
        path.put("length",1);
        path.put("relationships", asList(relationship1));
        path.put("end", node2);
        Path result = (Path)converter.convertToResultType(path, new TypeInformation(Path.class));

        assertEquals(SimplePath.class, result.getClass());
        assertEquals(1, result.startNode().getId());
        assertEquals(2, result.endNode().getId());
        assertEquals(1, result.lastRelationship().getId());
    }
View Full Code Here

        assertNull("no result",result);
        assertEquals(PATHS_COUNT, counter.get());
    }

    private List<Path> paths() {
        Path anyPath = mock(Path.class);
        Path[] paths=new Path[3];
        Arrays.fill(paths,anyPath);
        return Arrays.asList(paths);
    }
View Full Code Here

        };
    }

    private Path toPath( Path[] found, Node start )
    {
        Path startPath = found[0];
        Path endPath = found[1];
        if ( !startPath.startNode().equals( start ) )
        {
            Path tmpPath = startPath;
            startPath = endPath;
            endPath = tmpPath;
        }
        return toBuilder( startPath ).build( toBuilder( endPath ) );
    }
View Full Code Here

    {
        if ( !visitor.hasNext() )
        {
            return null;
        }
        Path position = visitor.next();
        Visit visit = visits.get( position.endNode() );
        if ( visit != null )
        {
            if ( visitor != visit.visitor )
            {
                return new Path[] { visit.position, position };
            }
        }
        else
        {
            visits.put( position.endNode(), new Visit( position, visitor ) );
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.neo4j.graphdb.Path

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.