def test_clear_delays(self): topo = fnss.star_topology(12) fnss.set_delays_constant(topo, 1, 'ms', None) self.assertEqual(topo.number_of_edges(), len(nx.get_edge_attributes(topo, 'delay'))) fnss.clear_delays(topo) self.assertEqual(0, len(nx.get_edge_attributes(topo, 'delay')))
def star(self, order, **args): """ Creates a Star-Topology Args: order (int): Number of nodes. args (dict): Attributes for property generation: min_bw (int): Minimal value for bandwidth on edge. max_bw (int): Maximal value for bandwidth on edge. bandwidth (string): {uniform, power} - How bandwidth should be generated. If uniform is chosen distribution follows uniform distribution, if power is chosen distribution follows a power law. min_cpu (int): Minimal value for CPU capacity. max_cpu (int): Maximal value for CPU capacity. min_distance (int): Minimal length of an edge. max_distance (int): Maximal length of an edge. delay (float, optional): Delay per kilometer of cable length. substrate (optional, bool): Whether it is a substrate network. Returns: FNSS object """ vnr = fnss.star_topology(order - 1) self.remove_unnecessary_attributes(args) self.generate_attributes(vnr, **args) vnr.graph['model'] = literals.NETWORK_MODEL_STAR return vnr
def test_clear_weights(self): # create new topology to avoid parameters pollution G = fnss.star_topology(12) fnss.set_weights_constant(G, 3, None) self.assertEqual(G.number_of_edges(), len(nx.get_edge_attributes(G, 'weight'))) fnss.clear_weights(G) self.assertEqual(0, len(nx.get_edge_attributes(G, 'weight')))
def test_star_connectivity(n): G = fnss.star_topology(n) self.assertEqual(n + 1, G.number_of_nodes()) self.assertEqual(n, G.number_of_edges()) self.assertEqual('root', G.node[0]['type']) for i in range(1, n + 1): self.assertEqual('leaf', G.node[i]['type']) self.assertTrue(G.has_edge(i, 0)) self.assertTrue(G.has_edge(0, i))
def test_star_connectivity(n): G = fnss.star_topology(n) self.assertEquals(n + 1, G.number_of_nodes()) self.assertEquals(n, G.number_of_edges()) self.assertEquals('root', G.node[0]['type']) for i in range(1, n + 1): self.assertEquals('leaf', G.node[i]['type']) self.assertTrue(G.has_edge(i, 0)) self.assertTrue(G.has_edge(0, i))
def test_fan_in_out_capacities_undirected(self): topology = fnss.star_topology(3) fnss.set_capacities_constant(topology, 10, 'Mbps') in_cap, out_cap = fnss.fan_in_out_capacities(topology) self.assertEquals({0: 30, 1: 10, 2: 10, 3: 10}, in_cap) self.assertEquals(in_cap, out_cap)
def test_fan_in_out_capacities_undirected(self): topology = fnss.star_topology(3) fnss.set_capacities_constant(topology, 10, 'Mbps') in_cap, out_cap = fnss.fan_in_out_capacities(topology) self.assertEqual({0: 30, 1: 10, 2: 10, 3: 10}, in_cap) self.assertEqual(in_cap, out_cap)