AGSNAMetrics.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGSNAMetrics {
@param
@throws
public static void main(String[] args) throws AllegroGraphException {
AllegroGraphConnection ags = new AllegroGraphConnection();
try {
ags.enable();
} catch (Exception e) {
throw new AllegroGraphException("Server connection problem", e);
}
AllegroGraph ts = ags.renew("snametrics", AGPaths.TRIPLE_STORES);
ts.registerNamespace("ex", "http://example.org/");
AGUtils.loadNTriplesWithTiming(ts, AGPaths.dataSources("sna-doublediamond.nt"));
SNAExtension sna = ts.getSNAExtension();
Object[] parts = new Object[2];
parts[0] = "objects-of";
parts[1] = "!ex:to";
sna.registerGenerator("to", parts);
String[] group = {"!ex:a","!ex:b","!ex:c","!ex:d","!ex:e","!ex:f","!ex:g","!ex:h"};
for (int i=0;i<group.length;i++) {
double bc = sna.getBetweennessCentrality(group[i], group, "to");
System.out.println("Betweenness Centrality of " + group[i] + " is " + bc);
}
for (int i=0;i<group.length;i++) {
double bc = sna.getClosenessCentrality(group[i], group, "to");
System.out.println("Closeness Centrality of " + group[i] + " is " + bc);
}
for (int i=0;i<group.length;i++) {
double bc = sna.getDegreeCentrality(group[i], group, "to");
System.out.println("Degree Centrality of " + group[i] + " is " + bc);
}
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next