Package com.tinkerpop.furnace.util

Examples of com.tinkerpop.furnace.util.VertexQueryBuilder


    public void testOutDegreeCalculation() {

        Graph graph = TinkerGraphFactory.createTinkerGraph();

        DegreeRankProgram program = DegreeRankProgram.create().degreeQuery(new VertexQueryBuilder().direction(Direction.OUT)).build();
        SerialGraphComputer computer = new SerialGraphComputer(graph, program, GraphComputer.Isolation.BSP);
        computer.execute();

        VertexMemory results = computer.getVertexMemory();
        assertEquals(results.getProperty(graph.getVertex(1), DegreeRankProgram.DEGREE), 3l);
View Full Code Here


    public void testBothCreatedDegreeCalculation() {

        Graph graph = TinkerGraphFactory.createTinkerGraph();

        DegreeRankProgram program = DegreeRankProgram.create().degreeQuery(new VertexQueryBuilder().direction(Direction.BOTH).labels("created")).build();
        SerialGraphComputer computer = new SerialGraphComputer(graph, program, GraphComputer.Isolation.BSP);
        computer.execute();

        VertexMemory results = computer.getVertexMemory();
        assertEquals(results.getProperty(graph.getVertex(1), DegreeRankProgram.DEGREE), 1l);
View Full Code Here

    public void testTraversalProgram() {
        Graph graph = TinkerGraphFactory.createTinkerGraph();

        TraversalProgram program = TraversalProgram.create().iterations(1)
                .addQuery(new VertexQueryBuilder().direction(Direction.IN).labels("created"))
                .addQuery(new VertexQueryBuilder().direction(Direction.OUT).labels("created")).build();
        SerialGraphComputer computer = new SerialGraphComputer(graph, program, GraphComputer.Isolation.BSP);
        computer.execute();

        VertexMemory results = computer.getVertexMemory();
        for (Vertex vertex : graph.getVertices()) {
View Full Code Here

    public void execute(final Vertex vertex, final GraphMemory graphMemory) {
        if (graphMemory.isInitialIteration()) {
            vertex.setProperty(COUNTS, 1l);
        } else {
            final VertexQueryBuilder query = this.queries.get((graphMemory.getIteration() - 1) % this.queries.size());
            long newCount = 0l;
            for (final Vertex adjacent : query.build(vertex).vertices()) {
                newCount = newCount + (Long) adjacent.getProperty(COUNTS);
            }
            vertex.setProperty(COUNTS, newCount);
        }
    }
View Full Code Here

TOP

Related Classes of com.tinkerpop.furnace.util.VertexQueryBuilder

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.