use of org.neo4j.graphalgo.impl.centrality.StressCentrality in project neo4j by neo4j.
the class ParallellCentralityCalculationTest method testPlusShape.
@Test
public void testPlusShape() {
// Make graph
graph.makeEdgeChain("a,b,c");
graph.makeEdgeChain("d,b,e");
SingleSourceShortestPath<Double> singleSourceShortestPath = getSingleSourceShortestPath();
ParallellCentralityCalculation<Double> pcc = new ParallellCentralityCalculation<Double>(singleSourceShortestPath, graph.getAllNodes());
BetweennessCentrality<Double> betweennessCentrality = new BetweennessCentrality<Double>(singleSourceShortestPath, graph.getAllNodes());
StressCentrality<Double> stressCentrality = new StressCentrality<Double>(singleSourceShortestPath, graph.getAllNodes());
ClosenessCentrality<Double> closenessCentrality = new ClosenessCentrality<Double>(singleSourceShortestPath, new DoubleAdder(), 0.0, graph.getAllNodes(), new CostDivider<Double>() {
public Double divideByCost(Double d, Double c) {
return d / c;
}
public Double divideCost(Double c, Double d) {
return c / d;
}
});
pcc.addCalculation(betweennessCentrality);
pcc.addCalculation(stressCentrality);
pcc.addCalculation(closenessCentrality);
pcc.calculate();
assertCentrality(betweennessCentrality, "a", 0.0);
assertCentrality(betweennessCentrality, "b", 6.0);
assertCentrality(betweennessCentrality, "c", 0.0);
assertCentrality(betweennessCentrality, "d", 0.0);
assertCentrality(betweennessCentrality, "e", 0.0);
assertCentrality(stressCentrality, "a", 0.0);
assertCentrality(stressCentrality, "b", 6.0);
assertCentrality(stressCentrality, "c", 0.0);
assertCentrality(stressCentrality, "d", 0.0);
assertCentrality(stressCentrality, "e", 0.0);
assertCentrality(closenessCentrality, "a", 1.0 / 7);
assertCentrality(closenessCentrality, "b", 1.0 / 4);
assertCentrality(closenessCentrality, "c", 1.0 / 7);
assertCentrality(closenessCentrality, "d", 1.0 / 7);
assertCentrality(closenessCentrality, "e", 1.0 / 7);
}
use of org.neo4j.graphalgo.impl.centrality.StressCentrality in project graphdb by neo4j-attic.
the class ParallellCentralityCalculationTest method testPlusShape.
@Test
public void testPlusShape() {
// Make graph
graph.makeEdgeChain("a,b,c");
graph.makeEdgeChain("d,b,e");
SingleSourceShortestPath<Double> singleSourceShortestPath = getSingleSourceShortestPath();
ParallellCentralityCalculation<Double> pcc = new ParallellCentralityCalculation<Double>(singleSourceShortestPath, graph.getAllNodes());
BetweennessCentrality<Double> betweennessCentrality = new BetweennessCentrality<Double>(singleSourceShortestPath, graph.getAllNodes());
StressCentrality<Double> stressCentrality = new StressCentrality<Double>(singleSourceShortestPath, graph.getAllNodes());
ClosenessCentrality<Double> closenessCentrality = new ClosenessCentrality<Double>(singleSourceShortestPath, new DoubleAdder(), 0.0, graph.getAllNodes(), new CostDivider<Double>() {
public Double divideByCost(Double d, Double c) {
return d / c;
}
public Double divideCost(Double c, Double d) {
return c / d;
}
});
pcc.addCalculation(betweennessCentrality);
pcc.addCalculation(stressCentrality);
pcc.addCalculation(closenessCentrality);
pcc.calculate();
// for ( Node node : graph.getAllNodes() )
// {
// System.out.println( "Dependency: " + graph.getNodeId( node ) + " "
// + stressCentrality.getCentrality( node ) );
// }
assertCentrality(betweennessCentrality, "a", 0.0);
assertCentrality(betweennessCentrality, "b", 6.0);
assertCentrality(betweennessCentrality, "c", 0.0);
assertCentrality(betweennessCentrality, "d", 0.0);
assertCentrality(betweennessCentrality, "e", 0.0);
assertCentrality(stressCentrality, "a", 0.0);
assertCentrality(stressCentrality, "b", 6.0);
assertCentrality(stressCentrality, "c", 0.0);
assertCentrality(stressCentrality, "d", 0.0);
assertCentrality(stressCentrality, "e", 0.0);
assertCentrality(closenessCentrality, "a", 1.0 / 7);
assertCentrality(closenessCentrality, "b", 1.0 / 4);
assertCentrality(closenessCentrality, "c", 1.0 / 7);
assertCentrality(closenessCentrality, "d", 1.0 / 7);
assertCentrality(closenessCentrality, "e", 1.0 / 7);
}
Aggregations