Comments (6)
Documentation is indeed lacking -- sincere apologies. There's an issue open for better documentation: #6.
To get the shortest path from node1 to node3, use the path
method on node1; here's its signature:
Node.prototype.path = function (toNode, relType, relDirection, maxDepth=1, algorithm='shortestPath', callback) {
...
}
At the moment, even though we have default values for maxDepth
and algorithm
, you still need to pass something for those parameters. It can be null
though to use the default values.
So your code is close; here it is corrected:
// get the path from barcelona to reus
bcn.path(reus, 'goes', 'out', 3, null /* for shortest path */, function(err, path) {
...
});
Note that I corrected "from reus to barcelona" to "from barcelona to reus", as your data has the relationships going from barcelona to reus. If you really do want to get the path backwards, you can switch bcn
and reus
and change the direction
to in
or all
instead of out
.
Hope that helps. Sorry again for the lack of documentation, and thanks for bringing it up.
from node-neo4j.
Btw, in general, we aren't focusing on these REST API methods much anymore, since you can achieve them with Cypher queries now. Cypher is both much simpler and much more powerful at letting you express exactly what you want.
(E.g. for shortest paths.)
But I see now that our Cypher wrapper doesn't properly handle returned paths. (Sorry, we only ever return nodes, rels and properties, so we never realized this.)
I'll leave this issue open to support paths in our Cypher wrapper. When we add this support, I'll post back here. Thanks.
from node-neo4j.
I see.
I take a eye on the cypher doc.
Thanks for all ;)
And yes, we are working on a path-finding app so we really need that paths.
Thanks again for the quickly response.
from node-neo4j.
Update here: returning paths in Cypher queries is now supported, in theory at least:
But a quick test is still needed to confirm this.
from node-neo4j.
Okay, added a test, fixed the code, and now indeed you can return paths in Cypher queries!
from node-neo4j.
Published to npm as v0.2.15.
from node-neo4j.
Related Issues (20)
- Can We omit the callback of tx.commit() ? HOT 6
- neo4j 3.x HOT 1
- Transaction expiration time depends on server timestamp HOT 1
- GraphDatabase instance does not have access to functions HOT 9
- TypeError: Uncaught error: Cannot read property 'length' of undefined HOT 3
- README broken link HOT 1
- multiple statements HOT 4
- basic example fails HOT 3
- Create DataBase Neo4j with node js HOT 2
- resultDataContents HOT 8
- Callback function not working when running with mocha/chai HOT 2
- Cannot create new node. HOT 1
- TypeError: Error.captureStackTrace is not a function HOT 11
- Cannot Read Property 'length' of undefined
- neo4j.ImpermanentGraphDatabase is not implemented it seems
- Promise-wrapped fails to catch HOT 5
- Params doesn't seem to work when passing inside WHERE query
- Support for koa.
- Project status? HOT 5
- Migration from thingdom driver to Drivine. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-neo4j.