For the sake of avoiding more loops, you may construct the graph like:

p = sic.shape[0]
X, Y = np.meshgrid(range(p), range(p))
graph = np.array((X[sic != 0], Y[sic != 0])).T

I have checked that it works using your code but maybe I misunderstood
something.