Ah Craig...two last info.....: I was wrong previously....I'm not sure if node 1 and node 2 are really directly connected...it depends on the OSM file; what I'm sure about is that I reduced to the minimum the complexity of my code by considering only 2 kind of relationships (the ones I put in the A* test) Moreover I use this code for A* code
public String testAStar(long idNodeStart, long idNodeEnd) { Transaction tx = this.graphDbService.beginTx(); try { Node startNode = graphDbService.getNodeById(idNodeStart); Node endNode = graphDbService.getNodeById(idNodeEnd); EstimateEvaluator<Double> estimateEvaluator = new EstimateEvaluator<Double >() { public Double getCost(final Node node, final Node goal) { double dx = (Double) node.getProperty(OSMAttribute.LONGITUDE_PROPERTY) - ( Double) goal.getProperty(OSMAttribute.LONGITUDE_PROPERTY); double dy = (Double) node.getProperty(OSMAttribute.LATITUDE_PROPERTY) - ( Double) goal.getProperty(OSMAttribute.LATITUDE_PROPERTY); double result = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); return result; } }; PathExpander expander = PathExpanders.forTypesAndDirections(RelTypes. CAR_BIDIRECTIONAL_RELATION, Direction.BOTH, RelTypes.CAR_ONEWAY_RELATION, Direction.OUTGOING); List<WeightedPath> paths = new ArrayList<WeightedPath>(); WeightedPath path = GraphAlgoFactory.aStar(expander, CommonEvaluators. doubleCostEvaluator(OSMAttribute.EDGE_LENGTH_PROPERTY), estimateEvaluator). findSinglePath(startNode, endNode);// tas.findSinglePath(startNode, String result = null; if( path != null ) { result = path.toString(); } tx.success(); return result; } catch (Exception e) { tx.failure(); logger.fatal(e.getMessage(), e); throw new IllegalStateException(e); } finally { if (tx != null) { tx.close(); } } } So I don't know if I'm wrong in using it or less...it seems to me I'm not wrong Anyway....I guess times are really too big... Il giorno lunedì 19 maggio 2014 19:41:05 UTC+2, Angelo Immediata ha scritto: > > Hi there > > We are using Neo4j 2.0.3 in order to build a routing system. We are using > the classical A Start implementation, tough we saw that there is a > TraversalAstar implementation but it seems to be in experimental status yet. > > By the way, we read an OSM file and create our graph; actually we have > around 1 million of points. around 2 million of relationships and around 5 > million of properites on relationships; by reading neo4j documentation it > seems to me that this DB dimension is really small and it's really well > handled by neo4j but in my case this doesn't seem to be real (maybe I'm > missing something) > > Actually our node creation code is the following one: > > private long createGraphNode(OsmNodeWrapper osmNodeWrapper) > { > try > { > Map<String, Object> nodeProps = new HashMap<String, Object>(); > double x = osmNodeWrapper.getLongitude(); > double y = osmNodeWrapper.getLatitude(); > nodeProps.put(OSMAttribute.LATITUDE_PROPERTY, y); > nodeProps.put(OSMAttribute.LONGITUDE_PROPERTY, x); > nodeProps.put(OSMAttribute.OSM_NODE_ID_PROPERTY, osmNodeWrapper. > getOsmNodeId()); > if (osmNodeWrapper.isTrafficSignal()) > nodeProps.put(OSMAttribute.TRAFFIC_SIGNAL, true); > // Creo il nodo > long graphNodeId = inserter.createNode(nodeProps, mainNodeLabel); > // aggiungo l'identificativo del nodo sul grafo > osmNodeWrapper.setGraphNodeId(graphNodeId); > return graphNodeId; > } > > In our graph, we have only 2 types of relationships: > > - *CAR_ONE_WAY_RELATION* for one way road with Direction OUTCOMING > - *CAR_BIDIRECTIONAL_WAY_RELATION* for bidirectional road with > Direction BOTH > > This is the relationship creation code: > //Create RelationShip > Map<String, Object> relationProps = new HashMap<String, Object>(); > relationProps.put(OSMAttribute.EDGE_LENGTH_PROPERTY, lunghezzaArco); > ....//other properties > long relId = inserter.createRelationship(startNode, endNode, > "CAR_ONE_WAY_RELATION", relationProps); > > osmWayIdPropertyIndex.add(relId, relationProps) > > We configured the neo4j embedded by using the following parameters: > > neostore.nodestore.db.mapped_memory=100M > neostore.relationshipstore.db.mapped_memory=3G > neostore.propertystore.db.mapped_memory=100M > neostore.propertystore.db.strings.mapped_memory=200M > neostore.propertystore.db.arrays.mapped_memory=50M > cache_type=strong > > As you can see we use a strong cache type; this means we cache all data in > memory. Moreover when out application starts we load all nodes and > properties in memory; n order to do this we use this code: > > > private void loadWholeGraphInMemory() throws PinfGraphServiceException{ > StopWatch sw = new StopWatch(); > sw.start(); > Node start; > for ( Node n : ggo.getAllNodes() ) { > n.getPropertyKeys(); > for ( Relationship relationship : n.getRelationships() ) { > start = relationship.getStartNode(); > } > } > for ( Relationship r : ggo.getAllRelationships() ) { > start = r.getStartNode(); > r.getPropertyKeys(); > } > sw.stop(); > logger.info("Grafo caricato in "+sw.getLastTaskTimeMillis()+" millis"); > > > } > > We tried to execute the AStar algorithm between 2 points. The distance > between points is around 130 kilometers. In order to execute the algorithm > Neo4j takes around 4 seconds for returning a path and it seems to me really > too much; if i compare it to other software on the same OSM I have really > really really really different performance. > Is there any way to improve the Algorithm performance? Where can we act to > have better performance? would be better to use the Traversal AStar? > Moreover is there any plan to implement bi-directional AStar and/or > Dijkstra? > > I guess that with this kind of perfomance, Neo4j is not suitable for my > scenario > > Thank you > Angelo > > > > > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.