Graph matrix into network flow

i like this post (click again to cancel)
0
i dont like this post (click again to cancel)

Hello,

I have this marix:

M=matrix(ZZ,6,9,[[1,1,1,0,0,0,0,0,0],[0,0,0,1,1,1,0,0,0],[0,0,0,0,0,0,1,1,1],[-1,0,0,-1,0,0,-1,0,0],[0,-1,0,0,-1,0,0,-1,0],[0,0,-1,0,0,-1,0,0,-1]])

and I am looking to get something like this:

image description

How can I do it?

asked Aug 06 '12

brenogil gravatar image brenogil
23 1 6
i like this answer (click again to cancel)
1
i dont like this answer (click again to cancel)

Hi,

If you just want the digraph, without the weights you can use

sage: D=DiGraph(M,format='incidence_matrix')

If you want to incorporate weights, you can try something like

sage: A=Matrix(ZZ,[[0,0,0,1,2,3],[0,0,0,4,5,6],[0,0,0,7,8,9],[0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0]])
sage: D=DiGraph(A,format='weighted_adjacency_matrix')
link

posted Aug 06 '12

fidbc gravatar image fidbc flag of Canada
908 2 9 27

Thank you! I do no know if I am missing some package or something but I cannot make the graph 'behave' like the picture above.

brenogil (Aug 07 '12)
1

If you want the vertex labels to appear as in your picture you might want to consider using the relabel method. For the edge labels to appear in the plot you can send an edge_labels=True argument to the plot method.

fidbc (Aug 07 '12)

Thanks for the hand! I'll pay you a beer whenever I am in Canada!

brenogil (Aug 08 '12)

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

1 follower

Tags:

Stats:

Asked: Aug 06 '12

Seen: 87 times

Last updated: Aug 06 '12

powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.