示例#1
0
 def test_generate_barabasi(self):
     """
     If no path is given, a generator and network parameters
     should be used to generate a network
     """
     config = {
         'network_params': {
             'generator': 'barabasi_albert_graph'
         }
     }
     with self.assertRaises(TypeError):
         G = utils.load_network(config['network_params'])
     config['network_params']['n'] = 100
     config['network_params']['m'] = 10
     G = utils.load_network(config['network_params'])
     assert len(G) == 100
示例#2
0
 def test_load_graph(self):
     """
     Load a graph from file if the extension is known.
     Raise an exception otherwise.
     """
     config = {
         'network_params': {
             'path': join(ROOT, 'test.gexf')
         }
     }
     G = utils.load_network(config['network_params'])
     assert G
     assert len(G) == 2
     with self.assertRaises(AttributeError):
         config = {
             'network_params': {
                 'path': join(ROOT, 'unknown.extension')
             }
         }
         G = utils.load_network(config['network_params'])
         print(G)