Beispiel #1
0
 def test_barabasi_albert_topology(self):
     self.assertRaises(ValueError, fnss.barabasi_albert_topology, 0, 20, 30)
     self.assertRaises(ValueError, fnss.barabasi_albert_topology, 50, 40, 20)
     self.assertRaises(ValueError, fnss.barabasi_albert_topology, 10, 40, 20)
     self.assertRaises(ValueError, fnss.barabasi_albert_topology, 50, -1, 20)
     self.assertRaises(ValueError, fnss.barabasi_albert_topology, 10, 11, 16)
     topology = fnss.barabasi_albert_topology(100, 11, 16)
     self.assertEqual(100, topology.number_of_nodes())
Beispiel #2
0
    def barabasi_albert(self, order, m=None, m0=None, **args):
        """
        Creates a scale free graph after the Barabasi-Albert model.

        Args:
            order (int): Number of nodes.
            m (int): Number of nodes a new node connects to.
            m0 (int): Number of initially connected 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

        """
        unconnected = True
        if m is None or m0 is None:
            m0 = 2
            m = 1

            if order > 2:
                m0 = int(np.random.uniform(2, order - 1))
                m = int(np.random.uniform(1, m0 - 1))
        vnr = None
        while unconnected:
            vnr = fnss.barabasi_albert_topology(n=order, m=m, m0=m0)
            unconnected = not nx.is_connected(vnr)
        self.remove_unnecessary_attributes(args)
        self.generate_attributes(vnr, **args)
        vnr.graph['model'] = literals.NETWORK_MODEL_BARABASI_ALBERT
        return vnr
Beispiel #3
0
 def test_barabasi_albert_topology_zero_seed(self):
     a = fnss.barabasi_albert_topology(100, 11, 16, seed=0)
     b = fnss.barabasi_albert_topology(100, 11, 16, seed=0)
     self.assertEqual(set(a.edges()), set(b.edges()))
Beispiel #4
0
 def test_barabasi_albert_topology_constant_seed(self):
     a = fnss.barabasi_albert_topology(100, 11, 16, seed=1)
     b = fnss.barabasi_albert_topology(100, 11, 16, seed=2)
     c = fnss.barabasi_albert_topology(100, 11, 16, seed=1)
     self.assertEqual(set(a.edges()), set(c.edges()))
     self.assertNotEqual(set(a.edges()), set(b.edges()))
Beispiel #5
0
 def test_barabasi_albert_topology_zero_seed(self):
     a = fnss.barabasi_albert_topology(100, 11, 16, seed=0)
     b = fnss.barabasi_albert_topology(100, 11, 16, seed=0)
     self.assertEqual(set(a.edges()), set(b.edges()))
Beispiel #6
0
 def test_barabasi_albert_topology_constant_seed(self):
     a = fnss.barabasi_albert_topology(100, 11, 16, seed=1)
     b = fnss.barabasi_albert_topology(100, 11, 16, seed=2)
     c = fnss.barabasi_albert_topology(100, 11, 16, seed=1)
     self.assertEqual(set(a.edges()), set(c.edges()))
     self.assertNotEqual(set(a.edges()), set(b.edges()))