use of org.gephi.graph.api.Graph in project gephi by gephi.
the class WeightedDegreeNGTest method testCompleteGraphDegree.
@Test
public void testCompleteGraphDegree() {
GraphModel graphModel = GraphGenerator.generateCompleteUndirectedGraph(5);
Graph graph = graphModel.getGraph();
Node n = graph.getNode("2");
WeightedDegree d = new WeightedDegree();
d.execute(graph);
assertEquals(n.getAttribute(WeightedDegree.WDEGREE), 4.0);
}
use of org.gephi.graph.api.Graph in project gephi by gephi.
the class HitsNGTest method testStarGraphHits.
@Test
public void testStarGraphHits() {
GraphModel graphModel = GraphGenerator.generateStarUndirectedGraph(5);
Graph graph = graphModel.getUndirectedGraph();
Hits hit = new Hits();
double[] authority = new double[6];
double[] hubs = new double[6];
HashMap<Node, Integer> indices = hit.createIndicesMap(graph);
hit.calculateHits(graph, hubs, authority, indices, false, EPSILON);
Node n1 = graph.getNode("0");
Node n3 = graph.getNode("2");
Node n4 = graph.getNode("3");
int index1 = indices.get(n1);
int index3 = indices.get(n3);
int index4 = indices.get(n4);
double hub1 = hubs[index1];
double hub3 = hubs[index3];
double auth1 = authority[index1];
double auth4 = authority[index4];
assertEquals(hub1, 0.4082);
assertEquals(auth1, 0.9128);
assertEquals(auth4, 0.1825);
assertEquals(hub1, hub3);
}
use of org.gephi.graph.api.Graph in project gephi by gephi.
the class HitsNGTest method testTwoConnectedNodesHits.
@Test
public void testTwoConnectedNodesHits() {
GraphModel graphModel = GraphGenerator.generateCompleteUndirectedGraph(2);
Graph graph = graphModel.getUndirectedGraph();
Hits hit = new Hits();
double[] authority = new double[2];
double[] hubs = new double[2];
HashMap<Node, Integer> indices = hit.createIndicesMap(graph);
hit.calculateHits(graph, hubs, authority, indices, false, EPSILON);
Node n1 = graph.getNode("0");
Node n2 = graph.getNode("1");
int index1 = indices.get(n1);
int index2 = indices.get(n2);
double hub1 = hubs[index1];
double auth2 = authority[index2];
assertEquals(hub1, 0.7071);
assertEquals(auth2, 0.7071);
}
use of org.gephi.graph.api.Graph in project gephi by gephi.
the class HitsNGTest method testCompleteGraphHits.
@Test
public void testCompleteGraphHits() {
GraphModel graphModel = GraphGenerator.generateCompleteUndirectedGraph(5);
Graph graph = graphModel.getUndirectedGraph();
Hits hit = new Hits();
double[] authority = new double[5];
double[] hubs = new double[5];
HashMap<Node, Integer> indices = hit.createIndicesMap(graph);
hit.calculateHits(graph, hubs, authority, indices, false, EPSILON);
Node n1 = graph.getNode("0");
Node n5 = graph.getNode("4");
int index1 = indices.get(n1);
int index5 = indices.get(n5);
double hub1 = hubs[index1];
double auth5 = authority[index5];
assertEquals(hub1, 0.4472);
assertEquals(auth5, 0.4472);
}
use of org.gephi.graph.api.Graph in project gephi by gephi.
the class HitsNGTest method testNullGraphHits.
@Test
public void testNullGraphHits() {
GraphModel graphModel = GraphGenerator.generateNullUndirectedGraph(5);
Graph graph = graphModel.getUndirectedGraph();
Hits hit = new Hits();
double[] authority = new double[5];
double[] hubs = new double[5];
HashMap<Node, Integer> indices = hit.createIndicesMap(graph);
hit.calculateHits(graph, hubs, authority, indices, false, EPSILON);
Node n2 = graph.getNode("1");
Node n3 = graph.getNode("2");
int index2 = indices.get(n2);
int index3 = indices.get(n3);
double hub2 = hubs[index2];
double auth3 = authority[index3];
assertEquals(hub2, 0.0);
assertEquals(auth3, 0.0);
}
Aggregations