@Test
public void testDirectedStarOutEigenvectorCentrality() {
GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
DirectedGraph directedGraph = graphModel.getDirectedGraph();
Node firstNode = graphModel.factory().newNode("0");
directedGraph.addNode(firstNode);
for (int i = 1; i <= 5; i++) {
Node currentNode = graphModel.factory().newNode(((Integer) i).toString());
directedGraph.addNode(currentNode);
Edge currentEdge = graphModel.factory().newEdge(firstNode, currentNode);
directedGraph.addEdge(currentEdge);
}
DirectedGraph hgraph = graphModel.getDirectedGraph();
EigenvectorCentrality ec = new EigenvectorCentrality();
double[] centralities = new double[6];
HashMap<Integer, Node> indicies = new HashMap();
HashMap<Node, Integer> invIndicies = new HashMap();
ec.fillIndiciesMaps(hgraph, centralities, indicies, invIndicies);
ec.calculateEigenvectorCentrality(hgraph, centralities, indicies, invIndicies, true, 100);
Node n1 = hgraph.getNode("0");
Node n2 = hgraph.getNode("1");
int index1 = invIndicies.get(n1);
int index2 = invIndicies.get(n2);
double ec1 = centralities[index1];
double ec2 = centralities[index2];