The following works nice:
G=Graph({0:[1,2],1:[2,3],2:[4]})
G.show()
But the following produces a wrong drawing
H=DiGraph({0:[1,2],1:[2,3],2:[4]})
H.show()
However, H.show3d() works fine
Now, there is another problem:
Say, I want to define a multigraph with selfloops, and edge labels..
One way to do this is:
import networkx
G=networkx.XDiGraph(selfloops=True,multiedges=True)
for i in range(3): G.add_node(i)
for i in [(1,1,'hola'),(1,1,'hi'),(1,2,'two'),(1,2,'dos'),
(2,1,'one')]: G.add_edge(i)
G=DiGraph(G)
Now, I would be tempted to just do the following:
G=DiGraph({1:{1:'hola',1:'hi',2:'two',2:'dos'},2:{1:'one'}},
loops=True, multiedges=True)
or trying
import networkx
G=networkx.XDiGraph({1:{1:'hola',1:'hi',2:'two',2:'dos'},2:{1:'one'}},
selfloops=True, multiedges=True)
But in each case I get:
G.edges()
(1, 1, 'h'), (1, 1, 'i'), (1, 2, 'd'), (1, 2, 'o'), (1, 2, 's'), (2,
1,
'o'), (2, 1, 'n'), (2, 1, 'e')]
Which is not as intended for two reasons: One is that the labels are
wrong, and the other one is that it created three edges from 1 to 2.
Any help?
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---