use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class GraphDistanceNGTest method testStarGraphAvPathLength.
@Test
public void testStarGraphAvPathLength() {
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 averageDegree = d.getPathLength();
double res = 1.6667;
double diff = Math.abs(averageDegree - res);
assertEquals(averageDegree, res, TOLERANCE);
}
use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class GraphDensityNGTest method testSelfLoopNodeDensity.
@Test
public void testSelfLoopNodeDensity() {
GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
Node currentNode = graphModel.factory().newNode("0");
undirectedGraph.addNode(currentNode);
Edge currentEdge = graphModel.factory().newEdge(currentNode, currentNode, false);
undirectedGraph.addEdge(currentEdge);
Graph graph = graphModel.getGraph();
GraphDensity d = new GraphDensity();
double density = d.calculateDensity(graph, false);
assertEquals(density, Double.POSITIVE_INFINITY);
}
use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class GraphDensityNGTest method testDirectedPathGraphDensity.
@Test
public void testDirectedPathGraphDensity() {
GraphModel graphModel = GraphGenerator.generatePathDirectedGraph(2);
DirectedGraph graph = graphModel.getDirectedGraph();
GraphDensity d = new GraphDensity();
double density = d.calculateDensity(graph, true);
assertEquals(density, 0.5);
}
use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class GraphDensityNGTest method testCyclicGraphDensity.
@Test
public void testCyclicGraphDensity() {
GraphModel graphModel = GraphGenerator.generateCyclicUndirectedGraph(6);
Graph graph = graphModel.getGraph();
GraphDensity d = new GraphDensity();
double density = d.calculateDensity(graph, false);
assertEquals(density, 0.4);
}
use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class GraphDensityNGTest method testDirectedCompleteGraphDensity.
@Test
public void testDirectedCompleteGraphDensity() {
GraphModel graphModel = GraphGenerator.generateCompleteDirectedGraph(5);
DirectedGraph graph = graphModel.getDirectedGraph();
GraphDensity d = new GraphDensity();
double density = d.calculateDensity(graph, true);
assertEquals(density, 1.0);
}
Aggregations