Cs50 Tideman Solution
The beginning is deceptively easy. You have to record preferences. If Alice beats Bob, Alice gets a point. Simple array work. I thought, "Hey, this isn't so bad."
Then came the graph.
The winner is the candidate with no incoming locked edges (i.e., no locked[j][i] true for any j).
Loop through each candidate, and if none of the other candidates have a locked edge pointing to them, that candidate wins. Cs50 Tideman Solution
To detect a cycle, we use a recursive depth-first search (DFS). The function cycle_check(int start, int end) determines if adding an edge from start to end closes a loop. The beginning is deceptively easy