For a project that I am doing, I decompose a graph that I created using NetworkX into an adjacency matrix using the NetworkX adj_matrix() function. However, one of the problems that I have come across is that every single graph that I decompose gives me the following error when I try to find the inverse of the matrix.
str: Traceback (most recent call last):
File "C:\eclipse\plugins\org.python.pydev.debug_1.4.7.2843\pysrc\pydevd_resolver.py", line 179, in _getPyDictionary
attr = getattr(var, n)
File "C:\Python26\lib\site-packages\numpy\core\defmatrix.py", line 519, in getI
return asmatrix(func(self))
File "C:\Python26\lib\site-packages\numpy\linalg\linalg.py", line 355, in inv
return wrap(solve(a, identity(a.shape[0], dtype=a.dtype)))
File "C:\Python26\lib\site-packages\numpy\linalg\linalg.py", line 254, in solve
raise LinAlgError, 'Singular matrix'
LinAlgError: Singular matrix
I tried generating adjacency matrices from 5 different graphs and all of them produced the same error when I tried to find the inverse of the adjacency matrix. The question that I pose is whether there is any way to go from NetworkX graph to matrix. What is my best course of action from here? I realize there are other questions pertaining to matrix inverses, but mine is somewhat limited by the fact that I need the graph adjacency matrix.