Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed 'sinks' method for undirected graph #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lynxaegon
Copy link

Fixes #101

@assafsun
Copy link

interesting issue :)
I'm trying to think is there is a meaning of sinks and sources in undirected graph as they are equal right?

@dforsber
Copy link

interesting issue :)
I'm trying to think is there is a meaning of sinks and sources in undirected graph as they are equal right?

What should sources() and sinks() return for a list of nodes without edges? Both return all the nodes?

@lynxaegon
Copy link
Author

lynxaegon commented Jan 20, 2021

interesting issue :)
I'm trying to think is there is a meaning of sinks and sources in undirected graph as they are equal right?

What should sources() and sinks() return for a list of nodes without edges? Both return all the nodes?

@dforsber from the API Reference:

# graph.sources()
Returns those nodes in the graph that have no in-edges. Takes O(|V|) time.

# graph.sinks()
Returns those nodes in the graph that have no out-edges. Takes O(|V|) time.

@assafsun is right, in an undirected graph, in-edges and out-edges are the same.

I was using graphlib for a mesh network graph (undirected ofc) and i was using sinks to determine that a node in the network wasn't connected to anything anymore (on disconnects). The sinks term was just better for me.
Looking back, i should probably update the PR to make the sources() and sinks() do the same thing for an undirected graph

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

Successfully merging this pull request may close these issues.

Sinks method returns incorrect output for undirected graph
3 participants