use of org.gephi.graph.api.GraphModel 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.GraphModel 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.GraphModel 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.GraphModel 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);
}
use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class GraphDistanceNGTest method testSpecial2DirectedGraphDiameter.
@Test
public void testSpecial2DirectedGraphDiameter() {
GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
DirectedGraph directedGraph = graphModel.getDirectedGraph();
Node node1 = graphModel.factory().newNode("0");
Node node2 = graphModel.factory().newNode("1");
Node node3 = graphModel.factory().newNode("2");
Node node4 = graphModel.factory().newNode("3");
Node node5 = graphModel.factory().newNode("4");
directedGraph.addNode(node1);
directedGraph.addNode(node2);
directedGraph.addNode(node3);
directedGraph.addNode(node4);
directedGraph.addNode(node5);
Edge edge12 = graphModel.factory().newEdge(node1, node2);
Edge edge14 = graphModel.factory().newEdge(node1, node4);
Edge edge23 = graphModel.factory().newEdge(node2, node3);
Edge edge25 = graphModel.factory().newEdge(node2, node5);
Edge edge35 = graphModel.factory().newEdge(node3, node5);
Edge edge43 = graphModel.factory().newEdge(node4, node3);
Edge edge51 = graphModel.factory().newEdge(node5, node1);
Edge edge54 = graphModel.factory().newEdge(node5, node4);
directedGraph.addEdge(edge12);
directedGraph.addEdge(edge14);
directedGraph.addEdge(edge23);
directedGraph.addEdge(edge25);
directedGraph.addEdge(edge35);
directedGraph.addEdge(edge43);
directedGraph.addEdge(edge51);
directedGraph.addEdge(edge54);
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 diameter = d.getDiameter();
assertEquals(diameter, 4.0, TOLERANCE);
}
Aggregations