Created
November 11, 2012 17:37
-
-
Save ib84/4055624 to your computer and use it in GitHub Desktop.
scala hypergraphdb demos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not yet functional as intended.