Git Product home page Git Product logo

Comments (6)

aseemk avatar aseemk commented on July 17, 2024

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.

aseemk avatar aseemk commented on July 17, 2024

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.

naxhh avatar naxhh commented on July 17, 2024

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.

aseemk avatar aseemk commented on July 17, 2024

Update here: returning paths in Cypher queries is now supported, in theory at least:

16a47be
1e0a795

But a quick test is still needed to confirm this.

from node-neo4j.

aseemk avatar aseemk commented on July 17, 2024

Okay, added a test, fixed the code, and now indeed you can return paths in Cypher queries!

0551fb2

from node-neo4j.

aseemk avatar aseemk commented on July 17, 2024

Published to npm as v0.2.15.

from node-neo4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.