use of org.gephi.graph.api.UndirectedGraph in project gephi by gephi.
the class GraphDistanceNGTest method testStarGraphBetweenness.
@Test
public void testStarGraphBetweenness() {
GraphModel graphModel = GraphGenerator.generateStarUndirectedGraph(5);
GraphDistance d = new GraphDistance();
d.initializeStartValues();
UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
HashMap<Node, Integer> indicies = d.createIndiciesMap(undirectedGraph);
HashMap<String, double[]> metricsMap = (HashMap) d.calculateDistanceMetrics(graphModel.getGraph(), indicies, false, false);
double[] betweenness = metricsMap.get(GraphDistance.BETWEENNESS);
Node n1 = undirectedGraph.getNode("0");
Node n2 = undirectedGraph.getNode("1");
int index1 = indicies.get(n1);
int index2 = indicies.get(n2);
assertEquals(betweenness[index1], 10.0, TOLERANCE);
assertEquals(betweenness[index2], 0.0, TOLERANCE);
}
use of org.gephi.graph.api.UndirectedGraph in project gephi by gephi.
the class GraphDistanceNGTest method testOneNodeRadius.
@Test
public void testOneNodeRadius() {
GraphModel graphModel = GraphGenerator.generateNullUndirectedGraph(1);
GraphDistance d = new GraphDistance();
d.initializeStartValues();
UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
HashMap<Node, Integer> indicies = d.createIndiciesMap(undirectedGraph);
d.calculateDistanceMetrics(graphModel.getGraph(), indicies, false, false);
double radius = d.getRadius();
assertEquals(radius, 0.0, TOLERANCE);
}
use of org.gephi.graph.api.UndirectedGraph in project gephi by gephi.
the class GraphDistanceNGTest method testPathGraphRadius.
@Test
public void testPathGraphRadius() {
GraphModel graphModel = GraphGenerator.generatePathUndirectedGraph(6);
GraphDistance d = new GraphDistance();
d.initializeStartValues();
UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
HashMap<Node, Integer> indicies = d.createIndiciesMap(undirectedGraph);
d.calculateDistanceMetrics(graphModel.getGraph(), indicies, false, false);
double radius = d.getRadius();
assertEquals(radius, 3.0, TOLERANCE);
}
use of org.gephi.graph.api.UndirectedGraph in project gephi by gephi.
the class GraphDistanceNGTest method testStarGraphRadius.
@Test
public void testStarGraphRadius() {
GraphModel graphModel = GraphGenerator.generateStarUndirectedGraph(5);
GraphDistance d = new GraphDistance();
d.initializeStartValues();
UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
HashMap<Node, Integer> indicies = d.createIndiciesMap(undirectedGraph);
d.calculateDistanceMetrics(graphModel.getGraph(), indicies, false, false);
double radius = d.getRadius();
assertEquals(radius, 1.0, TOLERANCE);
}
use of org.gephi.graph.api.UndirectedGraph in project gephi by gephi.
the class GraphDistanceNGTest method testDirectedCyclicRadius.
@Test
public void testDirectedCyclicRadius() {
GraphModel graphModel = GraphGenerator.generateCyclicDirectedGraph(5);
GraphDistance d = new GraphDistance();
d.initializeStartValues();
UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
HashMap<Node, Integer> indicies = d.createIndiciesMap(undirectedGraph);
d.calculateDistanceMetrics(graphModel.getGraph(), indicies, true, false);
double radius = d.getRadius();
assertEquals(radius, 4.0, TOLERANCE);
}
Aggregations