When you delete a node from a graph, to update your adjacency matrix you can either remove the column and row associated for that row. For example
Let node = 1 2 3
And its initial adjacency matrix be:
1 2 3
1 0 0 0
2 0 0 0
3 0 0 0
if you delete node 2, your adjacency matrix should remove all reference for node 2. Hence afterwards it should look like
1 3
1 0 0
3 0 0
Or you can take another approach, a flag approach, for example have -1 to mean deleted
1 2 3
1 0 -1 0
2 -1 -1 -1
3 0 -1 0
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608