aStar Routing method

66 views
Skip to first unread message

Carol Hansen

unread,
Jul 27, 2012, 4:32:34 PM7/27/12
to ne...@googlegroups.com
Hello,

I am trying to utilize the aStar routing method (took your advice, Rafal. Thank you!!) within the GraphAlgoFactory. But I am not sure how to utilize the "EstimateEvaluator". 
In the JavaDocs under "Use"...I obtained the following example
CommonEvaluators.geoEstimateEvaluator(String latitudePropertyKey, String longitudePropertyKey)  

1) Do I need to use geoEstimateEvaluator? My Nodes already have lat/lon properties in them. Do I simply pass the lat/lon for the endNode?

2) Also, am I using my Path variable ("route") properly? Will this return the actual path that I can then iterate through and print?

So far, I have the following code for my method:
   public void createRoute()
{
    PathFinder<Path> finder = GraphAlgoFactory.aStar(
                Traversal.expanderForTypes( RelTypes.OSM_NODENEXT, Direction.BOTH) , CommonEvaluators.doubleCostEvaluator("distance_in_meters"), EstimateEvaluator );
    String startNodeID;
String endNodeID;
Path route;
startNodeID = JOptionPane.showInputDialog("Enter nodeID for the Start Node: ");
endNodeID = JOptionPane.showInputDialog("Enter nodeID for the End Node: ");
 
long startNode = Long.valueOf(startNodeID);
  long endNode = Long.valueOf(endNodeID);
  Node start = graphDb.getNodeById(startNode);
  Node end = graphDb.getNodeById(endNode);
  route = finder.findSinglePath(start, end); 
 
}//end createRoute()


Thank you for any advice!

Peter Neubauer

unread,
Jul 28, 2012, 6:17:52 AM7/28/12
to ne...@googlegroups.com

Carol,
There is an example project at
https://github.com/neo4j-examples/java-astar-routing that you can look at?

/peter

Send from mobile.

Reply all
Reply to author
Forward
0 new messages