graph_tool.topology.shortest_distance() - Confusing documentation or possible bug in return_reached; wrong documentation

Hello everyone,

In the "shortest_distance" routine there is the option to return an array with the reached vertices by setting the flag/attribute "return_reached" to True. While using this routine, having set the max_dist, I have found that in the returned array not only are included the vertices in fact reached within the max_dist limit, but also some neighbouring vertices that probably were visited during the Dijkstra steps but exceeded the limit. I believe this behaviour is confusing and it may lead to erratic code/bugs for those who are not expecting it. I propose either:

1. Change the routine as to return only the vertices that are in fact reached within max_dist;
2. Change this flag to something like "return_visited", as to hint that the returned vertices may not in fact be reached within the expected distance limit;
3. Add a warning in the documentation regarding this behaviour.

Regarding the same method but on another subject, I believe there is an error in the documentation, namely on the return variables. There we can see two optional return values named "pred_map", while in fact one of them is the reached-vertices array mentioned above. Having the same name one may think that it might actually be a exclusive OR return where only either one is returned and it is just an matter of weird naming.

I may try to implement one of the changes above, if it is decided so, but the access to the GitLab repo through GitHub account linking has not been accepted by the admin yet.

JA

Dear João,

Hello everyone,

In the "shortest_distance" routine there is the option to return an array with the reached vertices by setting the flag/attribute "return_reached" to True. While using this routine, having set the max_dist, I have found that in the returned array not only are included the vertices in fact reached within the max_dist limit, but also some neighbouring vertices that probably were visited during the Dijkstra steps but exceeded the limit. I believe this behaviour is confusing and it may lead to erratic code/bugs for those who are not expecting it. I propose either:

1. Change the routine as to return only the vertices that are in fact reached within max_dist;
2. Change this flag to something like "return_visited", as to hint that the returned vertices may not in fact be reached within the expected distance limit;
3. Add a warning in the documentation regarding this behaviour.

The usual procedure when reporting bugs is to provide a minimal working
example that shows the problem. Otherwise we have to hunt blindly for an
instance of the behavior you are reporting.

Can you please provide a minimal example?

Regarding the same method but on another subject, I believe there is an error in the documentation, namely on the return variables. There we can see two optional return values named "pred_map", while in fact one of them is the reached-vertices array mentioned above. Having the same name one may think that it might actually be a exclusive OR return where only either one is returned and it is just an matter of weird naming.

This is indeed a bug in the documentation, and will be fixed. (Could you
please open an issue in gitlab so that it is not forgotten?)

I may try to implement one of the changes above, if it is decided so, but the access to the GitLab repo through GitHub account linking has not been accepted by the admin yet.

I have approved your account.

If you could open an issue for each bug with a minimal working example
that would be appreciated.

Best,
Tiago

Hello Tiago,

Thanks for the quick reply .
I don't have time for opening the issues right now, but I'll try to do so later today or tomorrow. Regardless, below you'll find a minimal example for the first issue I mentioned, for if you want to try it in the meantime.

Best regards,
JA