I have a graph represented as a numpy boolean array (G.adj.dtype == bool
). This is homework in writing my own graph library, so I can't use networkx. I want to dump it to a file so that I can fiddle with it, but for the life of me I can't work out how to make numpy dump it in a recoverable fashion.
I've tried G.adj.tofile
, which wrote the graph correctly (ish) as one long line of True/False. But fromfile
barfs on reading this, giving a 1x1 array, and loadtxt
raises a ValueError: invalid literal for int
. np.savetxt
works but saves the matrix as a list of 0/1 floats, and loadtxt(..., dtype=bool
) fails with the same ValueError.
Finally, I've tried networkx.from_numpy_matrix
with networkx.write_dot
, but that gave each edge [weight=True]
in the dot source, which broke networkx.read_dot
.