// Path: src/main/java/com/tinkerpop/furnace/algorithms/vertexcentric/GraphComputer.java
// public interface GraphComputer {
// 
//     public enum Isolation {
//         /**
//          * Computations are carried out in a bulk synchronous manner.
//          * The results of a vertex property update are only visible after the round is complete.
//          */
//         BSP,
//         /**
//          * Computations are carried out in a bulk synchronous manner.
//          * The results of a vertex property update are visible before the end of the round.
//          */
//         DIRTY_BSP
//     }
// 
//     /**
//      * Execute the GraphComputer's VertexProgram against the GraphComputer's graph.
//      * The GraphComputer must have reference to a VertexProgram and Graph.
//      * The typical flow of execution is:
//      *  1. Set up the VertexMemory as necessary given the VertexProgram (e.g. set compute keys).
//      *  2. Set up the GraphMemory as necessary given the VertexProgram.
//      *  3. Execute the VertexProgram
//      */
//     public void execute();
// 
//     /**
//      * Get the VertexSystemMemory cast as a VertexMemory to hide system specific methods.
//      *
//      * @return the GraphComputer's VertexMemory
//      */
//     public VertexMemory getVertexMemory();
// 
//     /**
//      * Get the GraphSystemMemory cast as a GraphMemory to hide system specific methods.
//      *
//      * @return the GraphComputer's GraphMemory
//      */
//     public GraphMemory getGraphMemory();
// }
// 
// Path: src/main/java/com/tinkerpop/furnace/algorithms/vertexcentric/VertexMemory.java
// public interface VertexMemory {
// 
//     public void setProperty(Vertex vertex, String key, Object value);
// 
//     public <T> T getProperty(Vertex vertex, String key);
// 
//     public <T> T removeProperty(Vertex vertex, String key);
// 
// }
// 
// Path: src/main/java/com/tinkerpop/furnace/algorithms/vertexcentric/programs/ranking/DegreeRankProgram.java
// public class DegreeRankProgram implements VertexProgram {
// 
//     protected VertexQueryBuilder degreeQuery = new VertexQueryBuilder().direction(Direction.IN);
//     private static final Map<String, KeyType> computeKeys = new HashMap<String, KeyType>();
// 
//     public static final String DEGREE = DegreeRankProgram.class.getName() + ".degree";
// 
//     static {
//         computeKeys.put(DEGREE, KeyType.CONSTANT);
//     }
// 
// 
//     protected DegreeRankProgram() {
// 
//     }
// 
//     public Map<String, KeyType> getComputeKeys() {
//         return computeKeys;
//     }
// 
//     public void setup(final GraphMemory graphMemory) {
// 
//     }
// 
//     public void execute(final Vertex vertex, final GraphMemory graphMemory) {
//         long degree = degreeQuery.build(vertex).count();
//         vertex.setProperty(DEGREE, degree);
//     }
// 
//     public boolean terminate(final GraphMemory graphMemory) {
//         return true;
//     }
// 
//     public static Builder create() {
//         return new Builder();
//     }
// 
//     //////////////////////////////
// 
//     public static class Builder {
// 
//         private final DegreeRankProgram vertexProgram = new DegreeRankProgram();
// 
//         public Builder degreeQuery(final VertexQueryBuilder degreeQuery) {
//             this.vertexProgram.degreeQuery = degreeQuery;
//             return this;
//         }
// 
//         public DegreeRankProgram build() {
//             return this.vertexProgram;
//         }
//     }
// }


import com.tinkerpop.blueprints.Graph;
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.programs.ranking.DegreeRankProgram;
import junit.framework.TestCase;
package com.tinkerpop.furnace.algorithms.vertexcentric.computers;


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

    public void testBasicSerialComputer() {
        Graph graph = TinkerGraphFactory.createTinkerGraph();
        DegreeRankProgram program = DegreeRankProgram.create().build();
        SerialGraphComputer computer = new SerialGraphComputer(graph, program, GraphComputer.Isolation.BSP);
        computer.execute();
// Path: src/main/java/com/tinkerpop/furnace/algorithms/vertexcentric/GraphComputer.java
// public interface GraphComputer {
// 
//     public enum Isolation {
//         /**
//          * Computations are carried out in a bulk synchronous manner.
//          * The results of a vertex property update are only visible after the round is complete.
//          */
//         BSP,
//         /**
//          * Computations are carried out in a bulk synchronous manner.
//          * The results of a vertex property update are visible before the end of the round.
//          */
//         DIRTY_BSP
//     }
// 
//     /**
//      * Execute the GraphComputer's VertexProgram against the GraphComputer's graph.
//      * The GraphComputer must have reference to a VertexProgram and Graph.
//      * The typical flow of execution is:
//      *  1. Set up the VertexMemory as necessary given the VertexProgram (e.g. set compute keys).
//      *  2. Set up the GraphMemory as necessary given the VertexProgram.
//      *  3. Execute the VertexProgram
//      */
//     public void execute();
// 
//     /**
//      * Get the VertexSystemMemory cast as a VertexMemory to hide system specific methods.
//      *
//      * @return the GraphComputer's VertexMemory
//      */
//     public VertexMemory getVertexMemory();
// 
//     /**
//      * Get the GraphSystemMemory cast as a GraphMemory to hide system specific methods.
//      *
//      * @return the GraphComputer's GraphMemory
//      */
//     public GraphMemory getGraphMemory();
// }
// 
// Path: src/main/java/com/tinkerpop/furnace/algorithms/vertexcentric/VertexMemory.java
// public interface VertexMemory {
// 
//     public void setProperty(Vertex vertex, String key, Object value);
// 
//     public <T> T getProperty(Vertex vertex, String key);
// 
//     public <T> T removeProperty(Vertex vertex, String key);
// 
// }
// 
// Path: src/main/java/com/tinkerpop/furnace/algorithms/vertexcentric/programs/ranking/DegreeRankProgram.java
// public class DegreeRankProgram implements VertexProgram {
// 
//     protected VertexQueryBuilder degreeQuery = new VertexQueryBuilder().direction(Direction.IN);
//     private static final Map<String, KeyType> computeKeys = new HashMap<String, KeyType>();
// 
//     public static final String DEGREE = DegreeRankProgram.class.getName() + ".degree";
// 
//     static {
//         computeKeys.put(DEGREE, KeyType.CONSTANT);
//     }
// 
// 
//     protected DegreeRankProgram() {
// 
//     }
// 
//     public Map<String, KeyType> getComputeKeys() {
//         return computeKeys;
//     }
// 
//     public void setup(final GraphMemory graphMemory) {
// 
//     }
// 
//     public void execute(final Vertex vertex, final GraphMemory graphMemory) {
//         long degree = degreeQuery.build(vertex).count();
//         vertex.setProperty(DEGREE, degree);
//     }
// 
//     public boolean terminate(final GraphMemory graphMemory) {
//         return true;
//     }
// 
//     public static Builder create() {
//         return new Builder();
//     }
// 
//     //////////////////////////////
// 
//     public static class Builder {
// 
//         private final DegreeRankProgram vertexProgram = new DegreeRankProgram();
// 
//         public Builder degreeQuery(final VertexQueryBuilder degreeQuery) {
//             this.vertexProgram.degreeQuery = degreeQuery;
//             return this;
//         }
// 
//         public DegreeRankProgram build() {
//             return this.vertexProgram;
//         }
//     }
// }


// Path: src/test/java/com/tinkerpop/furnace/algorithms/vertexcentric/computers/SerialGraphComputerTest.java
import com.tinkerpop.blueprints.Graph;
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.programs.ranking.DegreeRankProgram;
import junit.framework.TestCase;

package com.tinkerpop.furnace.algorithms.vertexcentric.computers;


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

    public void testBasicSerialComputer() {
        Graph graph = TinkerGraphFactory.createTinkerGraph();
        DegreeRankProgram program = DegreeRankProgram.create().build();
        SerialGraphComputer computer = new SerialGraphComputer(graph, program, GraphComputer.Isolation.BSP);
        computer.execute();
        VertexMemory results = computer.getVertexMemory();