Create weighted igraph Graph from numpy summetric 2D array as adjacency matrix
问题 I am having a numpy 2D array, with the values representing the weights of edges between nodes. The matrix is symmetric, and I take the diagonal to be zero. I don't find an example of how to convert this matrix into igraph Graph object. I've tried the following approach, but it doesn't work: 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()) 回答1: Use Graph.Weighted