Skip to content
This repository has been archived by the owner on Oct 21, 2021. It is now read-only.

provide Bool attribute to check for parents #145

Merged
merged 1 commit into from
Jan 1, 2015
Merged

provide Bool attribute to check for parents #145

merged 1 commit into from
Jan 1, 2015

Conversation

yeesian
Copy link
Contributor

@yeesian yeesian commented Jan 1, 2015

replaces #144, and closes #140

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 5c2e96b on yeesian:has-parents into 5b4889a on JuliaLang:master.

mlubin added a commit that referenced this pull request Jan 1, 2015
provide Bool attribute to check for parents
@mlubin mlubin merged commit 1b822fe into JuliaAttic:master Jan 1, 2015
@yeesian yeesian deleted the has-parents branch January 1, 2015 22:19
@yeesian yeesian mentioned this pull request Jan 1, 2015
@sbromberger
Copy link
Contributor

Hi,

Could I propose a change?

hasparent of the source right now returns true even though technically there's no parent to the source. Could we change this so that it returns false?

@@ -163,6 +163,7 @@ The following is an example that shows how to use this function:
The result has several fields, among which the following are most useful:

* ``parents[i]``: the parent vertex of the i-th vertex. The parent of each source vertex is itself.
* ``hasparent[i]``: ``true`` if the i-th vertex has a parent, and ``false`` otherwise. When ``hasparent[i] == false``, it means that the vertex at index ``i`` isn't reachable from any source. Note that ``hasparent[i] == true`` for all source vertices.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we change this so that hasparent[i] is false for source vertices?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for it? I thought this is consistent with the expectation that "the parent of each source is itself", and intended for hasparent to be a boolean mask for the parents attribute

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Technically, a node's parent is not itself unless there's an explicit edge between the node and itself, and that wouldn't ever exist (except possibly with A* and negative weights) in a shortest path calculation.

I don't know the original reason for making the source node its own parent, but it's not consistent with other packages (e.g., networkx) and will require an explicit check to ensure we're at the end of the (reversed) path so that we don't loop.

If we made this change, then the path enumeration can terminate on "hasparent=false".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree with you there. I'm just wondering whether this should be a local decision for hasparents (which I'll be happy to change), or whether it warrants opening an issue for the parents attribute as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's continue the discussion over at #150, just to make sure that there aren't other users whose code depends on this behavior

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to process dijkstra shortest path parents that return #undef?
5 participants