// Path: src/main/java/com/maxdemarzi/processing/centrality/DegreeArrayStorageParallelSPI.java
// public class DegreeArrayStorageParallelSPI implements Centrality {
//     private final GraphDatabaseAPI db;
//     private final int nodeCount;
//     private final ExecutorService pool;
//     private int[] degree;
//     private String directionName = "";
//     private final Direction direction;
// 
//     public DegreeArrayStorageParallelSPI(GraphDatabaseService db, ExecutorService pool, Direction direction) {
//         this.pool = pool;
//         this.db = (GraphDatabaseAPI)db;
//         this.nodeCount = new NodeCounter().getNodeCount(db);
//         this.direction = direction;
//         if (!direction.equals(Direction.BOTH)) {
//             directionName = direction.name().toLowerCase() + "_";
//         }
//     }
// 
//     @Override
//     public void compute(String label, String type, int iterations) {
//         degree = new int[nodeCount];
//         Arrays.fill(degree, -1);
// 
//         try ( Transaction tx = db.beginTx()) {
//             ThreadToStatementContextBridge ctx = this.db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
//             ReadOperations ops = ctx.get().readOperations();
//             int labelId = ops.labelGetForName(label);
//             int relationshipTypeId = ops.relationshipTypeGetForName(type);
// 
//             PrimitiveLongIterator it = ops.nodesGetForLabel(labelId);
//             int totalCount = nodeCount;
//             runOperations(pool, it, totalCount, ops, new OpsRunner() {
//                 public void run(int id) throws EntityNotFoundException {
//                     degree[id] = ops.nodeGetDegree(id, direction, relationshipTypeId);
//                 }
//             });
// 
//             tx.success();
//         } catch (Exception e) {
//             e.printStackTrace();
//         }
//     }
// 
//     @Override
//     public double getResult(long node) {
//         return degree != null ? degree[(int) node] : 0;
//     }
// 
//     @Override
//     public long numberOfNodes() {
//         return nodeCount;
//     }
// 
//     @Override
//     public String getPropertyName() {
//         return  directionName + "degree_centrality";
//     }
// }
// 
// Path: src/test/java/com/maxdemarzi/processing/TestUtils.java
// public class TestUtils {
//     static public Map<String, Object> getPersonEntry(String name, GraphDatabaseService db) {
//         try (Result result = db.execute(TestObjects.PERSON_RESULT_QUERY, Collections.singletonMap("name", name))) {
//             return result.next();
//         }
//     }
// 
//     static public Map<String, Object> getMovieEntry(String title, GraphDatabaseService db) {
//         try (Result result = db.execute(TestObjects.MOVIE_RESULT_QUERY, Collections.singletonMap("title", title))) {
//             return result.next();
//         }
//     }
// }


import com.maxdemarzi.processing.centrality.DegreeArrayStorageParallelSPI;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.neo4j.test.TestGraphDatabaseFactory;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static com.maxdemarzi.processing.TestUtils.*;
            db.execute(TestObjects.KNOWS_QUERY);
            tx.success();
        }
    }

    @After
    public void tearDown() throws Exception {
        db.shutdown();
    }

    @Test
    public void shouldCalculateInDegreeCentrality() throws IOException {
        String response = service.inDegree("Movie", "ACTED_IN", db);
        assertEquals("InDegree Centrality for Movie and ACTED_IN Completed!", response);
    }

    @Test
    public void shouldCalculateOutDegreeCentrality() throws IOException {
        String response = service.outDegree("Person", "ACTED_IN", db);
        assertEquals("OutDegree Centrality for Person and ACTED_IN Completed!", response);
    }

    @Test
    public void shouldCalculateDegreeCentrality() throws IOException {
        String response = service.degree("Person", "ACTED_IN", db);
        assertEquals("Degree Centrality for Person and ACTED_IN Completed!", response);
    }

    @Test
    public void shouldCalculateInDegreeCentralityArrayStorageSPI() throws IOException {
// Path: src/main/java/com/maxdemarzi/processing/centrality/DegreeArrayStorageParallelSPI.java
// public class DegreeArrayStorageParallelSPI implements Centrality {
//     private final GraphDatabaseAPI db;
//     private final int nodeCount;
//     private final ExecutorService pool;
//     private int[] degree;
//     private String directionName = "";
//     private final Direction direction;
// 
//     public DegreeArrayStorageParallelSPI(GraphDatabaseService db, ExecutorService pool, Direction direction) {
//         this.pool = pool;
//         this.db = (GraphDatabaseAPI)db;
//         this.nodeCount = new NodeCounter().getNodeCount(db);
//         this.direction = direction;
//         if (!direction.equals(Direction.BOTH)) {
//             directionName = direction.name().toLowerCase() + "_";
//         }
//     }
// 
//     @Override
//     public void compute(String label, String type, int iterations) {
//         degree = new int[nodeCount];
//         Arrays.fill(degree, -1);
// 
//         try ( Transaction tx = db.beginTx()) {
//             ThreadToStatementContextBridge ctx = this.db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
//             ReadOperations ops = ctx.get().readOperations();
//             int labelId = ops.labelGetForName(label);
//             int relationshipTypeId = ops.relationshipTypeGetForName(type);
// 
//             PrimitiveLongIterator it = ops.nodesGetForLabel(labelId);
//             int totalCount = nodeCount;
//             runOperations(pool, it, totalCount, ops, new OpsRunner() {
//                 public void run(int id) throws EntityNotFoundException {
//                     degree[id] = ops.nodeGetDegree(id, direction, relationshipTypeId);
//                 }
//             });
// 
//             tx.success();
//         } catch (Exception e) {
//             e.printStackTrace();
//         }
//     }
// 
//     @Override
//     public double getResult(long node) {
//         return degree != null ? degree[(int) node] : 0;
//     }
// 
//     @Override
//     public long numberOfNodes() {
//         return nodeCount;
//     }
// 
//     @Override
//     public String getPropertyName() {
//         return  directionName + "degree_centrality";
//     }
// }
// 
// Path: src/test/java/com/maxdemarzi/processing/TestUtils.java
// public class TestUtils {
//     static public Map<String, Object> getPersonEntry(String name, GraphDatabaseService db) {
//         try (Result result = db.execute(TestObjects.PERSON_RESULT_QUERY, Collections.singletonMap("name", name))) {
//             return result.next();
//         }
//     }
// 
//     static public Map<String, Object> getMovieEntry(String title, GraphDatabaseService db) {
//         try (Result result = db.execute(TestObjects.MOVIE_RESULT_QUERY, Collections.singletonMap("title", title))) {
//             return result.next();
//         }
//     }
// }


// Path: src/test/java/com/maxdemarzi/processing/DegreeCentralityTest.java
import com.maxdemarzi.processing.centrality.DegreeArrayStorageParallelSPI;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.neo4j.test.TestGraphDatabaseFactory;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static com.maxdemarzi.processing.TestUtils.*;

            db.execute(TestObjects.KNOWS_QUERY);
            tx.success();
        }
    }

    @After
    public void tearDown() throws Exception {
        db.shutdown();
    }

    @Test
    public void shouldCalculateInDegreeCentrality() throws IOException {
        String response = service.inDegree("Movie", "ACTED_IN", db);
        assertEquals("InDegree Centrality for Movie and ACTED_IN Completed!", response);
    }

    @Test
    public void shouldCalculateOutDegreeCentrality() throws IOException {
        String response = service.outDegree("Person", "ACTED_IN", db);
        assertEquals("OutDegree Centrality for Person and ACTED_IN Completed!", response);
    }

    @Test
    public void shouldCalculateDegreeCentrality() throws IOException {
        String response = service.degree("Person", "ACTED_IN", db);
        assertEquals("Degree Centrality for Person and ACTED_IN Completed!", response);
    }

    @Test
    public void shouldCalculateInDegreeCentralityArrayStorageSPI() throws IOException {
        DegreeArrayStorageParallelSPI inDegree = new DegreeArrayStorageParallelSPI(db, pool, Direction.INCOMING);