Revision 80be5642 mininet/topo.py

View differences:

mininet/topo.py
98 98
        self.ports = {} # ports[src][dst] is port on src that connects to dst
99 99
        self.id_gen = NodeID # class used to generate dpid
100 100

  
101
    def _add_node(self, dpid, node):
101
    def add_node(self, dpid, node):
102 102
        '''Add Node to graph.
103 103

  
104 104
        @param dpid dpid
......
107 107
        self.g.add_node(dpid)
108 108
        self.node_info[dpid] = node
109 109

  
110
    def _add_edge(self, src, dst, edge = None):
110
    def add_edge(self, src, dst, edge = None):
111 111
        '''Add edge (Node, Node) to graph.
112 112

  
113 113
        @param src src dpid
......
119 119
        if not edge:
120 120
            edge = Edge()
121 121
        self.edge_info[(src, dst)] = edge
122
        self._add_port(src, dst)
122
        self.add_port(src, dst)
123 123

  
124
    def _add_port(self, src, dst):
124
    def add_port(self, src, dst):
125 125
        '''Generate port mapping for new edge.
126 126

  
127 127
        @param src source switch DPID
......
329 329

  
330 330
        self.k = k
331 331

  
332
        self._add_node(1, Node())
332
        self.add_node(1, Node())
333 333
        hosts = range(2, k + 2)
334 334
        for h in hosts:
335
            self._add_node(h, Node(is_switch = False))
336
            self._add_edge(h, 1, Edge())
335
            self.add_node(h, Node(is_switch = False))
336
            self.add_edge(h, 1, Edge())
337 337

  
338 338
        if enable_all:
339 339
            self.enable_all()
......
388 388
        switches = range(1, k + 1)
389 389
        for s in switches:
390 390
            h = s + k
391
            self._add_node(s, Node())
392
            self._add_node(h, Node(is_switch = False))
393
            self._add_edge(s, h, Edge())
391
            self.add_node(s, Node())
392
            self.add_node(h, Node(is_switch = False))
393
            self.add_edge(s, h, Edge())
394 394
        for s in switches:
395 395
            if s != k:
396
                self._add_edge(s, s + 1, Edge())
396
                self.add_edge(s, s + 1, Edge())
397 397

  
398 398
        if enable_all:
399 399
            self.enable_all()

Also available in: Unified diff