I would appreciate any comments.
There is a function called Adjacency(matrix, mode=ADJ_DIRECTED) which supposedly generates a graph from its adjacency matrix.
I am not sure what I am doing wrong in the following code.

I have a question of my own, since I am not terribly comfortable with either igraphâ€™s Python interface or Python itself:

@tamas Is there a way to avoid the conversion from an efficient numpy array to an inefficient list of lists? Is there some sort of â€śunifiedâ€ť matrix interface (or de-facto standard) in Python that could be used to make this work with any matrix type? How about sparse arrays (adjacency matrices are best stored as sparse arrays)?

There is no unified matrix interface as far as I know.

In the C layer, we are calling igraph_adjacency(), which needs an igraph_matrix_t. Internally, igraph_matrix_t is simply a continuous chunk of memory with the values of the matrix cells, in either row major or column major order (canâ€™t remember which, Iâ€™d have check the source code). In theory, we could get hold of the internal memory buffer of the NumPy matrix and create an igraph_matrix_view() out of it, assuming that the NumPy matrix is also continuous - which might not always be the case as NumPy multi-dimensional arrays can be sliced in a way that the underlying memory buffer remains the same and NumPy only adjusts the â€śstridesâ€ť one has to take along a particular axis in order to get to the next cell along that axis. So, one way or another, we need to convert the NumPy representation to something that igraph_matrix_view() can then digest.

I thank you all. It may be worth changing the document on Adjacency as well as Weighted-Adjacency since both ask for matrix as the input. As you all point out, instead one needs to give a list of lists as input.

Sid
Siddhartha Dalal, Professor
Columbia University