Weighted adjacency matrix of a graph.
The code:
G=Graph(sparse=True, weighted=True)
G.add_edges([(0, 1, i), (0,8,1),(1,2,1),(2,3,1),(3,4,1),(4,5,1),(4,6,1),(6,7,1),(6,8,1),(8,9,1)])
M = G.weighted_adjacency_matrix()
show(M)
Here the (1,0) entry in the output matrix will be i, but I need -i. For that purpose, even I had defined (1,0,-i), it is not coming. Please give some hint.
Probably you should create a
DiGraph
fromG
. Do you need the weight of (directed) edge(w,v)
to be minus the weight of(v,w)
?