def testBranchCoeff4(self):
     # this has 3 fragments: 2 dimers and a pentamer, which is branched
     adj = dok_matrix((9, 9), dtype=np.float32)
     adj_dict = {
         (4, 8): 8.0,
         (8, 4): 8.0,
         (7, 3): 8.0,
         (3, 7): 8.0,
         (0, 2): 5.0,
         (2, 0): 8.0,
         (4, 2): 4.0,
         (2, 4): 5.0,
         (5, 6): 8.0,
         (6, 5): 5.0,
         (1, 2): 8.0,
         (2, 1): 4.0
     }
     for key, val in adj_dict.items():
         adj[key] = val
     branch_degree = list(degree(adj))
     good_branch_degree = [1, 1, 3, 1, 2, 1, 1, 1, 1]
     self.assertTrue(branch_degree == good_branch_degree)
     branch_coeff = overall_branching_coefficient(adj)
     good_branch_coeff = 1 / 9
     self.assertAlmostEqual(branch_coeff, good_branch_coeff)
 def testBranchCoeff3(self):
     adj = dok_matrix((10, 10), dtype=np.float32)
     adj_dict = {
         (0, 1): 8.0,
         (1, 0): 8.0,
         (1, 2): 4.0,
         (2, 1): 8.0,
         (2, 3): 4.0,
         (3, 2): 8.0,
         (3, 4): 5.0,
         (4, 3): 8.0,
         (5, 4): 8.0,
         (4, 5): 5.0,
         (5, 6): 4.0,
         (6, 5): 8.0,
         (7, 8): 8.0,
         (8, 7): 8.0,
         (0, 8): 4.0,
         (8, 0): 5.0,
         (8, 9): 4.0,
         (9, 8): 8.0
     }
     for key, val in adj_dict.items():
         adj[key] = val
     branch_degree = list(degree(adj))
     good_branch_degree = [2, 2, 2, 2, 2, 2, 1, 1, 3, 1]
     self.assertTrue(branch_degree == good_branch_degree)
     branch_coeff = overall_branching_coefficient(adj)
     good_branch_coeff = 0.1
     self.assertAlmostEqual(branch_coeff, good_branch_coeff)
 def testBranchCoeff1(self):
     # testing dimers and a monomer
     adj = ADJ2
     mono_degree = list(degree(adj))
     good_mono_degree = [1, 1, 1, 1]
     self.assertTrue(mono_degree == good_mono_degree)
     branch_coeff = overall_branching_coefficient(adj)
     self.assertTrue(branch_coeff == 0)
 def testBranchCoeff2(self):
     # testing timer and dimers
     adj = ADJ3
     branch_degree = list(degree(adj))
     good_branch_degree = [2, 1, 1]
     self.assertTrue(branch_degree == good_branch_degree)
     branch_coeff = overall_branching_coefficient(adj)
     self.assertTrue(branch_coeff == 0)
 def testDegree0(self):
     # Testing all monomers
     adj = ADJ_ZEROS
     mono_degree = list(degree(adj))
     good_mono_degree = []
     self.assertTrue(mono_degree == good_mono_degree)
     branch_coeff = overall_branching_coefficient(adj)
     self.assertTrue(branch_coeff == 0)