topo: make new minimal Graph object a Graph, not a DiGraph
Fixes another Graph regression relative to NetworkX.
RipL broke because the NetworkX Graph object that was used previously
for topologies is an undirected graph:
>>> import networkx as nx
>>> g=nx.Graph()
>>> g.add_edge(0,1)
>>> g[1]
{0: {}}
>>> g[0]
{1: {}}
There is a separate DiGraph object in NetworkX for directed behavior.
The minimal replacement previously implemented DiGraph behavior.
>>> from mininet.topo import Graph
>>> g2=Graph()
>>> g2.add_edge(0,1)
>>> g2[0]
[1]
>>> g2[1]
[]
This commit restores undirected graph behavior.
This commit is contained in:
@@ -29,6 +29,7 @@ class Graph( object ):
|
||||
self.add_node( src )
|
||||
self.add_node( dest )
|
||||
self.data[ src ].append( dest )
|
||||
self.data[ dest ].append( src )
|
||||
|
||||
def nodes( self ):
|
||||
"Return list of graph nodes"
|
||||
|
||||
Reference in New Issue
Block a user