use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class ClusteringCoefficientNGTest method testCompleteGraphClusteringCoefficient.
@Test
public void testCompleteGraphClusteringCoefficient() {
GraphModel graphModel = GraphGenerator.generateCompleteUndirectedGraph(5);
Graph graph = graphModel.getGraph();
ClusteringCoefficient cc = new ClusteringCoefficient();
cc.setDirected(false);
ArrayWrapper[] network = new ArrayWrapper[5];
int[] triangles = new int[5];
double[] nodeClustering = new double[5];
HashMap<String, Double> results = cc.computeClusteringCoefficient(graph, network, triangles, nodeClustering, false);
double avClusteringCoefficient = results.get("clusteringCoefficient");
assertEquals(avClusteringCoefficient, 1.0);
}
use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class DegreeNGTest method testSelfLoopGraphDegree.
@Test
public void testSelfLoopGraphDegree() {
GraphModel graphModel = GraphGenerator.generateSelfLoopUndirectedGraph(1);
Graph graph = graphModel.getGraph();
Node n = graph.getNode("0");
Degree d = new Degree();
int degree = d.calculateDegree(graph, n);
assertEquals(degree, 2);
}
use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class DegreeNGTest method testCyclicGraphDegree.
@Test
public void testCyclicGraphDegree() {
GraphModel graphModel = GraphGenerator.generateCyclicUndirectedGraph(5);
Graph graph = graphModel.getGraph();
Node n = graph.getNode("3");
Degree d = new Degree();
int degree = d.calculateDegree(graph, n);
double avDegree = d.calculateAverageDegree(graph, false, false);
assertEquals(degree, 2);
assertEquals(avDegree, 2.0);
}
use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class DegreeNGTest method testNullGraphDegree.
@Test
public void testNullGraphDegree() {
GraphModel graphModel = GraphGenerator.generateNullUndirectedGraph(5);
Graph graph = graphModel.getGraph();
Node n = graph.getNode("1");
Degree d = new Degree();
int degree = d.calculateDegree(graph, n);
double avDegree = d.calculateAverageDegree(graph, false, false);
assertEquals(degree, 0);
assertEquals(avDegree, 0.0);
}
use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class DegreeNGTest method testStarGraphDegree.
@Test
public void testStarGraphDegree() {
GraphModel graphModel = GraphGenerator.generateStarUndirectedGraph(5);
Graph graph = graphModel.getGraph();
Node n1 = graph.getNode("0");
Node n2 = graph.getNode("1");
Degree d = new Degree();
int degree1 = d.calculateDegree(graph, n1);
int degree2 = d.calculateDegree(graph, n2);
double avDegree = d.calculateAverageDegree(graph, false, false);
double expectedAvDegree = 1.6667;
double diff = Math.abs(avDegree - expectedAvDegree);
assertEquals(degree1, 5);
assertEquals(degree2, 1);
assertTrue(diff < 0.001);
}
Aggregations