Python Forum

Full Version: Remove isolated vertices from dictionary and adjacency matrix
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Greetings Community,

I have a dictionary and an adjacency matrix looking as follows:
dict: {0: (171,331, 1: (168,358), ...} (a list of vertices with coordinates)
adjacency matrix: 2d array which only contains zeros and ones for connected (1) or unconnected (0)

The two structures are connected in a way that the order of the adjacency matrix is equal to the enumeration of the dictionary.

Now I would like to be able to remove all isolated vertices (where row/column only contains zeros) from the adjacency matrix and also from the dictionary.

Is there a way to do this properly in python? Would you recommend a different data structure in python?
Not relevant anymore, my implementation is not giving me the expected result anyway, will have to look into the networkx bibliography and see if it is possible to generate random connected graphs with given minimum node degree. Even better would be unit disc graphs but I doubt I find that.