Package com.tinkerpop.furnace.algorithms.vertexcentric.programs.paths

Source Code of com.tinkerpop.furnace.algorithms.vertexcentric.programs.paths.TraversalProgramTest

package com.tinkerpop.furnace.algorithms.vertexcentric.programs.paths;

import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.tg.TinkerGraphFactory;
import com.tinkerpop.furnace.algorithms.vertexcentric.GraphComputer;
import com.tinkerpop.furnace.algorithms.vertexcentric.VertexMemory;
import com.tinkerpop.furnace.algorithms.vertexcentric.computers.SerialGraphComputer;
import com.tinkerpop.furnace.util.VertexQueryBuilder;
import junit.framework.TestCase;

/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class TraversalProgramTest extends TestCase {

    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()) {
            System.out.println(vertex.getProperty("name") + "\t" + results.getProperty(vertex, TraversalProgram.COUNTS));
        }
    }
}
TOP

Related Classes of com.tinkerpop.furnace.algorithms.vertexcentric.programs.paths.TraversalProgramTest

TOP
Copyright © 2018 www.massapi.com. 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.