Subscribe

getPath() exception, no message

  1. 2011-09-07 15:07:38 PDT
    Firstly, sorry if I am missing something obvious. Please let me know in that case with a pointer, and I'll take it from there. But here's what I am facing: dijkstra's shortestpath getPath() returns an exception with message: "Edges: ......." where the dots are actually a list of all edge and node objects in the memory printed alternately. This exception happens at edu.uci.ics.jung.algorithms.shortestpath.DijkstraShortestPath.getPath(DijkstraShortestPath.java:164) I don't have a way to know what is going on? Is this because there is (probably) not a path between the nodes I am specifying? Thanks in anticipation for help! Shubhanan
  2. 2011-09-07 15:16:45 PDT
    Shubhanan: You can easily test to see whether there is a path by calculating the shortest paths from your source vertex and trying to retrieve the distance to the destination vertex. If the answer is "null" then you can't get there from here. Please post the entire stack trace. getPath() itself shouldn't be throwing that exception. Joshua
  3. 2011-09-07 15:34:01 PDT
    Fyi: I know there is a path between the two nodes I am passing as arguments to the getPath() method.
  4. 2011-09-07 15:35:32 PDT
    You know this now, or you already knew this earlier and I misunderstood your original path? Is the graph directed? Joshua
  5. 2011-09-07 15:47:23 PDT
    Hi Joshua, Thanks for your reply. Actually, I didn't see any of your comments until my page reloaded with mine, just a few moments ago. The graph is directed, and I know there is a directed path between the two nodes I am passing as argument to getPath(). I confirmed it just before I posted my last comment. I am generating the stack trace again (starting the server and processes and regenerating the exception), and will post it here. Till then - All I see in the stack trace is "Edges: myedge@hashCode mynode@hashCode myedge@hashCode mynode@hashCode...." and so on .. a long list. And where is spits this is at edu.uci.ics.jung.algorithms.shortestpath.DijkstraShortestPath.getPath(DijkstraShortestPath.java:164) . Every call after this in the stack trace are my methods (just invocations with arguments, as it runs fine with other pairs of nodes). Could this long list be because the graph finds a cycle? Thanks, Shubhanan
  6. 2011-09-07 15:54:26 PDT
    Shubhanan: The exception being thrown on line 164 (http://jung.cvs.sourceforge.net/viewvc/jung/jung2/jung-algorithms/src/main/java/edu/uci/ics/jung/algorithms/shortestpath/DijkstraShortestPath.java?revision=1.12&view=markup) is one that you get if the target vertex is not in the specified graph. Not sure why you're not seeing the entire message. It's generally useful to look at the source if you have trouble interpreting the error message. This is the beauty of open-source. :) Joshua
  7. 2011-09-07 15:56:45 PDT
    Alright, it seems the messages were stripped randomly in the earlier logs :-O. I don't know why. It now says (on the eclipse output) I'm passing a vertex that's not a part of the graph. But the earlier logs didn't show this line (and many others) printed before the Edges:..... list; may be a broken logger. So I know the cause now. Sorry for taking your time, and apologies for a problem on our side created this confusion over getPath()/api. Thanks anyways! Shubhanan
  8. 2011-09-07 15:58:54 PDT
    Joshua, you were spot on! You're right, I should have looked up the source. Hence forth. Getting used to using OSS. :) Shubhanan
  9. 2011-09-07 15:59:48 PDT
    We probably ought to be more conservative either about how the toString() is constructed for a Graph, or about when we include the toString() in a message. For large graphs just generating that message could be problematic. :P Thanks for bringing that to our attention (even if that wasn't your original intent). :) Joshua
  10. 2011-09-07 18:34:12 PDT
    Good point. And nice of you to pick that up! I thought instead of printing objects (name@hashCode), probably let the user extend toString or some other method (say, name()) for edges and nodes and use that for printing the graph. That might be more helpful since I can relate better to it, if a list of nodes (I guess from toString() of the graph) be included in the message. Again, I haven't looked at the code, so I don't know if this is already there :D. Yet, just a thought. Thanks!
  11. 2011-09-07 18:36:09 PDT
    Or if I override toString, it will automatically happen!?! Looks like I am too tired lol, I think I should go home now, its already 9.30pm Adios!
Jump To:
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.