-
Notifications
You must be signed in to change notification settings - Fork 84
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
Change deadlock cycle detection algorithm to a general one for directed graphs #195
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable
Have you considered just ripping this part out and replacing it to a link to something with a more detailed explanation of cycle detection as an algorithm? I'm sure there's better resources out there, maybe even with pictures.
return false; | ||
} | ||
|
||
bool _is_cyclic(const graph* g, const void* root, set* visited, set* current_path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_graph_contains_cycle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function names are now consistent.
I failed to find a high-quality explanation that explains the algorithm clearly and provides enough context for a student to be able to easily implement this algorithm in C using the toolchain provided by CS 341. Do you have recommendations @aneeshdurg? |
Description
This PR changes the cycle detection algorithm taught in the deadlock chapter to a generic one for directed graphs. The current algorithm in the textbook has the following problems (possible solutions also outlined):
I would argue that we should change the algorithm taught: there is not much point in teaching a specialized algorithm (it’s general for undirected graphs but RAGs aren’t undirected) and risk confusing students for years. During my office hour, none of the students using the specialized algorithm was aware that it works for RAGs: once I gave them an example of a directed graph that fails the algorithm, they were not able to argue that such a graph is not a valid RAG. And the fact that I gave the examples shows that I wasn’t aware either.
We can still mention the specialized algorithm somewhere as an exercise for capable readers.
Related Issues
N/A
Checklist
Breaking Change
Does this cause any new material not previously covered in the course to be required?