walkccc / CLRS

📚 Solutions to Introduction to Algorithms Third Edition
https://walkccc.me/CLRS
MIT License
4.63k stars 1.26k forks source link

Solution to 22.1 - 4 is Wrong #433

Open nshmadhani opened 2 years ago

nshmadhani commented 2 years ago

Current solution does overrides the previous value of edges from u to v.

if there is and edge between 1 -> 3, 2 -> 3, 3 -> 1 -> 2. Then A[3] will be first 1 and then A[3] = 2.

This would override the previous value and 3->1 will be included in the graph.

nshmadhani commented 2 years ago

A should be a matrix of |V| * |V| and edges should be marked as A[v][u] = 1, to know if any edge has been repeated