Skip to content
karussell edited this page Feb 16, 2013 · 6 revisions

Example Usage without Location2Index

// Creating and saving the graph
GraphBuilder gb = new GraphBuilder().location("some-folder").store(true);
GraphStorage graph = gb.create();
// Make a weighted edge between two nodes. False means the edge is directed.
graph.edge(fromId, toId, cost, false);
// Store to disc
graph.flush();

// Loading and using the graph
GraphStorage graph = gb.load();
Path path = new DijkstraSimple().calcPath(fromId, toId);

Now with Prepare graph

// Creating and saving the graph
GraphBuilder gb = new GraphBuilder().location("some-folder").store(true).levelGraph(true);
GraphStorage graph = gb.create();
// Make a weighted edge between two nodes. False means the edge is directed.
graph.edge(fromId, toId, cost, false);
// Prepare the graph for fast querying ...
new PrepareContractionHierarchies().graph(graph).doWork();
graph.flush();

// Loading and using the graph
GraphStorage graph = gb.load();
algorithm = new PrepareContractionHierarchies().graph(graph).createAlgo();
Path path = algorithm.calcPath(fromId, toId);
Clone this wiki locally