Skip to content

Instantly share code, notes, and snippets.

@ib84
Created November 11, 2012 17:37
Show Gist options
  • Save ib84/4055624 to your computer and use it in GitHub Desktop.
Save ib84/4055624 to your computer and use it in GitHub Desktop.
scala hypergraphdb demos
private static HGHandle linkLine(String [] stations, HyperGraph graph){
HGHandle[] stationHandles = new HGHandle[stations.length];
for (int i = 0; i < stations.length; i++){
stationHandles[i] = hg.assertAtom(graph, stations[i]);
}
return graph.add(new HGPlainLink(stationHandles));
}
public static void main(String[] args) {
HyperGraph graph = new HyperGraph("//home/ingvar/bin/sbt-KK/bje");
HGHandle m2 = linkLine(new String[]{"Nation", "Avron", "Alexandre Dumas", "Phillipe Auguste","Père Lachaise", "Ménilmontant", "Couronnes", "Belleville", "Colonel Fabien"}, graph);
HGHandle m11 = linkLine(new String[]{"République","Goncourt", "Belleville", "Pyrénees"}, graph);
HGHandle m3 = linkLine(new String[]{"République","Oberkampf", "Parmentier", "Rue Saint-Maur","Père Lachaise"}, graph);
HGHandle m9 = linkLine(new String[]{"République","Nation"}, graph);
HGHandle nationHandle = hg.assertAtom(graph, "Nation");
HGALGenerator alGen = new DefaultALGenerator(graph, hg.type(HGPlainLink.class), hg.type(String.class),false, true, false);
HGTraversal trav= new HGBreadthFirstTraversal(nationHandle, alGen);
while(trav.hasNext()){
Pair<HGHandle, HGHandle> pair = trav.next();
System.out.println("\nTraversing. Current word: " + graph.get(pair.getSecond()));
}
graph.close();
@ib84
Copy link
Author

ib84 commented Nov 11, 2012

not yet functional as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment