From 4e1630e126a4e942d7836a8717d9af1798109f07 Mon Sep 17 00:00:00 2001 From: Brandon Heller Date: Thu, 20 Jun 2013 16:27:13 -0700 Subject: [PATCH] topo: add __getitem__ for Graph Commit 65c35b65 'Remove networkx dependency' broke this line from RipL: nodes = [n for n in self.g[name] if self.layer(n) == layer] To work around this, RipL code would have to be changed to something like this: nodes = [n for n in self.g.data[name] if self.layer(n) == layer] ...which would use an internal variable, data. It seems cleaner to add this one little feature from NetworkX Graph objects. --- mininet/topo.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mininet/topo.py b/mininet/topo.py index cae1c04..d09004c 100644 --- a/mininet/topo.py +++ b/mininet/topo.py @@ -40,6 +40,10 @@ class Graph( object ): for dest in self.data[ src ]: yield ( src, dest ) + def __getitem__( self, node ): + "Return link dict for the given node" + return self.data[node] + class Topo(object): "Data center network representation for structured multi-trees."