I am learning python-igraph, and having difficulty in handling a graph which is divided to components (which are unconnected between them). When I apply one of the clustering algorithms on this graph it doesn't seem to work properly, and so I need to apply the algorithms to each subgraph (component) separately. So in order to maintain the identification of the vertices, I would like to add a vertex attribute that give me the id number in the original graph. My graph is constructed from a weighted adjacency matrix:
import numpy as np
import igraph
def symmetrize(a):
return a + a.T - 2*np.diag(a.diagonal())
A = symmetrize(np.random.random((100,100)))
G = igraph.Graph.Adjacency(A.tolist(),attr="weight",mode="UPPER")
I see that there should be a way to add vertex attributes, but I don't understand how to use it..