What should the behavior be for shortest path from node to itself - BUG

20 views
Skip to first unread message

Jatin Puri

unread,
Sep 16, 2014, 1:17:28 PM9/16/14
to ne...@googlegroups.com
There is a bug in GraphAlgoFactory (trivial but never the less irritating). Basically if you try finding a single shortest path from a node to itself, it gives following behavior:

Using  `GraphAlgoFactory.astar`, it throws:
org.neo4j.graphdb.NotFoundException: Relationship -1 not found

Using `GraphAlgoFactory.dijskstra`, it returns:
A Path starting (WeightedPath#startNode) from the node and ending (WeightedPath#endNode) at itself but with no relationship between them.

I looked at the source and found the bug in each and was rectifying it. But I am not sure what the behavior should be. 

Documentation says that it should return null if no path is found. But for a path from a node to itself, should we assume it as a self-loop with no weight, given there is no explicit relationship between node to itself? Or is the behavior of `dijkstra` correct? (I think its wrong)

Mattias Persson

unread,
Sep 18, 2014, 3:52:12 AM9/18/14
to Neo4j Development
Yup looks like a bug to me. I'm one of the authors of that algo implementation, so I'll see if I can have a look at it soon.

--
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Mattias Persson
Neo4j Hacker at Neo Technology

Jatin Puri

unread,
Sep 18, 2014, 4:16:00 AM9/18/14
to ne...@googlegroups.com
Hi Mattias,

Thanks for response. I will probably try patching it and send pull request. Also this will get me more involved more in it :)
About the behavior, what should it be? `null` or a path starting from node to itself? I couldn't find relevant documentation for it

Jatin

--
You received this message because you are subscribed to a topic in the Google Groups "Neo4j" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/neo4j/5B3BLyRR_ww/unsubscribe.
To unsubscribe from this group and all its topics, send an email to neo4j+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Mattias Persson

unread,
Sep 18, 2014, 7:28:45 AM9/18/14
to Neo4j Development
I think it makes sense to return a path consisting of just the one node that is start/end. Although I don't know if A* has some standard result for this scenario.

Great to hear that you'd like to have a look and dig around yourself! Please ask more questions in this thread if you'd like to get hints about code navigation or the likes.
Reply all
Reply to author
Forward
0 new messages