-
Notifications
You must be signed in to change notification settings - Fork 820
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
Bug in NaiveLcaFinder #490
Comments
What did you do to debug this issue? |
Since the NaiveLcaFinder class constructor only ensures that the graph must be directed but does not check if it contains a cycle. LCAs must be found on DAGs but for the given test, I later realised that it was not a DAG. It was supposed to be a DAG but it was not. Should I go ahead and implement this check? |
No, it would not be a good idea to add this as a check. There's always a trade-off between: spending computational effort on input validation, and just assuming that the user provides the correct input. I currently don't have access to the code, but what you could do is:
Nevertheless, double check whether there doesn't exist already some method equivalent to the isDirectedAcyclicGraph test (I don't know this by heart). |
For my project tentatively, I modified the |
@hulk-baba There is a problem with your input file. I get Cersei when I run my implementation with "Robert Cersei" (which is not really correct but there is an edge from Cersei to Robert; as it is from Robert to Cersei in the input file) as its input with my version of the input file. Please check your input file again and let me know if you find something (or maybe try a smaller graph that you simulates part of the Lannister/Baratheon subgraph and it's easier to debug). |
@AlexandruValeanu please try with same input file with different arguments |
@hulk-baba You are right. It doesn't work in that case. A set of common ancestors would be This is not a problem with the actual implementation as the graph is not a DAG (the cycle between Robert and Cersei creates problems in the Lannister/Baratheon subgraph). Possible fixes:
|
@AlexandruValeanu So are we assuming that the given graph is incorrect and then removing the edge from |
@tibrewalpratik17 For the warmup challenge, it's better to simply modify the graph so that it no longer contains any cycles. You can use My implementation of |
@AlexandruValeanu okay... but what if a user enters a cyclic graph and expects an output so the valid output in that case should be null if any of the recent ancestors of the given nodes or may be the nodes itself is involved in a cycle right? |
The user should not expect an answer, in that case, the user must validate their input, it is just as saying what is f(x) for input x, not in the domain of f, the answer is not null but not defined. |
@tibrewalpratik17 If the input is not a DAG then the output should not be trusted. It can literally be anything. In this case, I believe that my implementation returns only lcas that are not part of a cycle but I am not really certain as I haven't tested how |
Can someone please close this as it is not a bug? |
Hello all, while trying to parse a dot file I used a graph whose all LCAs should be
Robert
andCersei
but instead, received nothing. Please check if it really is a bug. This bug happens to be in functionfindLcas
of NaiveLcaFinder.The text was updated successfully, but these errors were encountered: