954,487 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Deleting a Node in an Adjacency Matrix Graph

I have a Graph that I'm making using an adjacency matrix to hold edge values. The noEdge value is zero and all edgeweights are positive integers. I have to delete a node from this graph and I'm having trouble figuring out how to update the Adjacency matrix after the deletion of the label from my labels vector. I know I have to shift the values but I can't quite figure out in code/algorithm format.

Any idea on a good way to implement this in code/an algorithm?

Thanks

dolfan55aj
Newbie Poster
5 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

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
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: