AGSNAGenerators.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGSNAGenerators {
@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("snagenerators", 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-objects", parts);
parts[0] = "subjects-of";
parts[1] = "!ex:to";
sna.registerGenerator("to-subjects", parts);
parts[0] = "undirected";
parts[1] = "!ex:to";
sna.registerGenerator("to-undirected", parts);
String[] group = {"!ex:a","!ex:b","!ex:c","!ex:d","!ex:e","!ex:f","!ex:g","!ex:h"};
String[] generators = {"to-objects","to-subjects","to-undirected"};
for (int i=0;i<group.length;i++) {
for (int j=0;j<generators.length;j++){
long nodalDegree = sna.getNodalDegree(group[i], generators[j]);
System.out.println("Nodal Degree of " + group[i] + " using " + generators[j] + " is " + nodalDegree);
}
}
for (int i=0;i<group.length;i++) {
for (int j=0;j<generators.length;j++){
UPI[] nodalNeighbors = sna.getNodalNeighbors(group[i], generators[j]);
System.out.println("Nodal Neighbors of " + group[i] + " using " + generators[j] + " are "
+ AGUtils.upiArrayToString(ts,nodalNeighbors));
}
}
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next