Skip to content

fix is_cyclic #157

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

Merged
merged 0 commits into from
Aug 25, 2022
Merged

fix is_cyclic #157

merged 0 commits into from
Aug 25, 2022

Conversation

aurorarossi
Copy link
Member

issue #34, now is_cyclic works for undirected connected graphs.

@@ -10,7 +10,7 @@ Return `true` if graph `g` contains a cycle.
Uses DFS.
"""
function is_cyclic end
@traitfn is_cyclic(g::::(!IsDirected)) = ne(g) > 0
@traitfn is_cyclic(g::::(!IsDirected)) = (ne(g)-(nv(g)-1)) > 0
Copy link
Member

Choose a reason for hiding this comment

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

I think this not enough, consider the cyclic graph of 5 vertices

1  -- 2       4 -- 5
  \  /
    3

then nv(g) == 5 and ne(g) == 4, so that ne(g) - (nv(g) - 1)) == 0. We therefore probably need do check every connceted component separately.

@simonschoelly
Copy link
Member

Thanks for your contribution, I think we should indeed change how this function works for undirected graphs. We probably also need to adapt the tests (that are currently failing) and the documentation for the changed behavior.

@aurorarossi
Copy link
Member Author

Yes, this was an improvement only for connected graphs. I'm going to extend it to unconnected ones.
Thank you!

@aurorarossi aurorarossi marked this pull request as draft August 25, 2022 14:04
@aurorarossi aurorarossi merged commit a3fb98b into JuliaGraphs:master Aug 25, 2022
@etiennedeg
Copy link
Member

Hmm, I'm not sure what happened here? Did you try rebasing the PR?

@aurorarossi
Copy link
Member Author

yes

@etiennedeg
Copy link
Member

new PR here

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.

3 participants