Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

why cannot recalculate (2)?

html("

From Dictionary to Matrix (2)

") @interact def newtarph( D=input_box(default={0: {1: 2, 2: 3}, 1: {0: 3, 2: 4}, 2: {3: 2, 4: 1}, 3: {0: 2, 1: 3, 4: 1}}, label='Dictionary')): G = DiGraph(D) W= G.weighted_adjacency_matrix() n=G.num_verts() C=[(i,j) for (i,j) in CartesianProduct(range(n),range(n)) if (W[i][j]<>0)] E0=matrix(C) V=vector([W[i][j] for (i,j) in C]) E=column_matrix([E0.column(0),E0.column(1),V]) print E

click to hide/show revision 2
No.2 Revision

why cannot recalculate (2)?

html("

html("<h1> From Dictionary to Matrix (2)

")
(2)</h1>") @interact def newtarph( D=input_box(default={0: {1: 2, 2: 3}, 1: {0: 3, 2: 4}, 2: {3: 2, 4: 1}, 3: {0: 2, 1: 3, 4: 1}}, label='Dictionary')): G = DiGraph(D) W= G.weighted_adjacency_matrix() n=G.num_verts() C=[(i,j) for (i,j) in CartesianProduct(range(n),range(n)) if (W[i][j]<>0)] E0=matrix(C) V=vector([W[i][j] for (i,j) in C]) E=column_matrix([E0.column(0),E0.column(1),V]) print E

E