Skip to content
Snippets Groups Projects
Commit 5b48a7d9 authored by Bob Lantz's avatar Bob Lantz
Browse files

Reimplemented and corrected Graph as MultiGraph

fixes #172
parent 4316be95
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@
from mininet.util import irange, natural, naturalSeq
class Graph( object ):
class MultiGraph( object ):
"Utility class to track nodes and edges - replaces networkx.Graph"
def __init__( self ):
......@@ -21,15 +21,14 @@ def __init__( self ):
def add_node( self, node ):
"Add node to graph"
if node not in self.data.keys():
self.data[ node ] = []
self.data.setdefault( node, [] )
def add_edge( self, src, dest ):
"Add edge to graph"
src, dest = sorted( ( src, dest ) )
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"
......@@ -54,7 +53,7 @@ def __init__(self, hopts=None, sopts=None, lopts=None):
hinfo: default host options
sopts: default switch options
lopts: default link options"""
self.g = Graph()
self.g = MultiGraph()
self.node_info = {}
self.link_info = {} # (src, dst) tuples hash to EdgeInfo objects
self.hopts = {} if hopts is None else hopts
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment