NetworkX

Previous topic

networkx.adjacency_spectrum

Next topic

networkx.laplacian

networkx.adj_matrix

adj_matrix(G, nodelist=None)

Return adjacency matrix of graph as a numpy matrix.

This just calls networkx.convert.to_numpy_matrix.

If you want a pure python adjacency matrix represntation try networkx.convert.to_dict_of_dicts with weighted=False, which will return a dictionary-of-dictionaries format that can be addressed as a sparse matrix.