1,105,578 Community Members

Deleting a Node in an Adjacency Matrix Graph

Member Avatar
dolfan55aj
Newbie Poster
5 posts since Sep 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
firstPerson
Industrious Poster
4,052 posts since Dec 2008
Reputation Points: 761 [?]
Q&As Helped to Solve: 634 [?]
Skill Endorsements: 24 [?]
 
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
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: