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

Incorrect behaviour in findCycles (unexistent edges) #99

Open
ErunamoJAZZ opened this issue Jan 17, 2019 · 2 comments
Open

Incorrect behaviour in findCycles (unexistent edges) #99

ErunamoJAZZ opened this issue Jan 17, 2019 · 2 comments

Comments

@ErunamoJAZZ
Copy link

I found a strange case where findeCycles returns a wrong response.

This is what g.edges() show:

[ { v: '3', w: '1' },
  { v: '9', w: '5' },
  { v: '8', w: '9' },
  { v: '18', w: '6' },
  { v: '19', w: '4' },
  { v: '19', w: '5' },
  { v: '21', w: '6' },
  { v: '21', w: '9' },
  { v: '23', w: '22' },
  { v: '23', w: '21' },
  { v: '23', w: '10' },
  { v: '18', w: '23' },
  { v: '18', w: '7' },
  { v: '27', w: '21' },
  { v: '27', w: '19' },
  { v: '27', w: '18' },
  { v: '5', w: '6' },
  { v: '5', w: '27' },
  { v: '49', w: '27' },
  { v: '4', w: '54' },
  { v: '3', w: '21' },
  { v: '4', w: '55' },
  { v: '55', w: '56' },
  { v: '53', w: '56' },
  { v: '54', w: '56' },
  { v: '52', w: '56' },
  { v: '50', w: '56' },
  { v: '51', w: '56' },
  { v: '3', w: '55' },
  { v: '35', w: '26' },
  { v: '1', w: '59' },
  { v: '2', w: '59' },
  { v: '2', w: '58' },
  { v: '1', w: '58' },
  { v: '1', w: '56' },
  { v: '2', w: '56' },
  { v: '59', w: '1' },
  { v: '58', w: '1' },
  { v: '35', w: '1' },
  { v: '57', w: '1' },
  { v: '56', w: '1' },
  { v: '1', w: '53' },
  { v: '2', w: '53' },
  { v: '58', w: '2' },
  { v: '59', w: '2' },
  { v: '57', w: '2' },
  { v: '56', w: '2' },
  { v: '35', w: '2' },
  { v: '3', w: '2' },
  { v: '1', w: '55' },
  { v: '2', w: '55' },
  { v: '59', w: '6' },
  { v: '58', w: '6' },
  { v: '57', w: '6' },
  { v: '56', w: '6' },
  { v: '35', w: '6' },
  { v: '3', w: '6' },
  { v: '2', w: '54' },
  { v: '1', w: '54' },
  { v: '59', w: '54' },
  { v: '3', w: '54' },
  { v: '58', w: '54' },
  { v: '57', w: '54' },
  { v: '56', w: '54' },
  { v: '35', w: '54' } ]

And this is what alg.findCycles(g) returns:

[ [ '59', '58', '55', '54', '2', '56', '53', '1' ], [ '19', '23', '18', '27', '5', '9', '21' ] ]

As you can see, most of edges are fine compared to the cycles found, but by example, there is not a relation between '59' and '58'!

I am not sure why it is happening, but I will let this case here, maybe someone will found what is happening here.

@antoinerg
Copy link

@ErunamoJAZZ It seems to me that although 59 and 58 are not directly connected, they still form a cycle through their connections to 1:

{ v: '1', w: '58' },
{ v: '58', w: '1' },
{ v: '1', w: '59' },
{ v: '59', w: '1' },

Please correct me if I'm wrong but I think the result is correct.

@ErunamoJAZZ
Copy link
Author

ErunamoJAZZ commented Feb 6, 2019

Nice, it is true that it could explain why the algorithm found that response, thank you antoinerg.
But anyway, it is an unexpected behavior of what I understand for a cycle over a directed graph.

In this function I thought in a simple cycle or directed cycle, not in a circuit (following the terms used in wikipedia https://en.wikipedia.org/wiki/Cycle_(graph_theory) ).

So, even knowing why, it still being a wrong result for our usercase.

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

No branches or pull requests

2 participants