コード例 #1
0
ファイル: test_metrics.py プロジェクト: shitou333111/brainx
 def test_nodal_efficiency_conn(self):
     n_eff_array = metrics.nodal_efficiency(self.g)
     desired = (1.0 / (self.n_nodes - 1) * np.array([
         1 + 1 + 1 / 2.0 + 1 / 3.0, 1 + 1 + 1 / 2.0 + 1 / 3.0, 1 + 1 + 1 +
         1 / 2.0, 1 / 2.0 + 1 / 2.0 + 1 + 1, 1 / 3.0 + 1 / 3.0 + 1 / 2.0 + 1
     ]))
     npt.assert_array_almost_equal(n_eff_array, desired)
コード例 #2
0
ファイル: test_metrics.py プロジェクト: EhsanTadayon/brainx
 def test_nodal_efficiency_conn(self):
     n_eff_array = metrics.nodal_efficiency(self.g)
     desired = (1.0 / (self.n_nodes - 1) *
                np.array([1 + 1 + 1 / 2.0 + 1 / 3.0,
                          1 + 1 + 1 / 2.0 + 1 / 3.0,
                          1 + 1 + 1 + 1 / 2.0,
                          1 / 2.0 + 1 / 2.0 + 1 + 1,
                          1 / 3.0 + 1 / 3.0 + 1 / 2.0 + 1]))
     npt.assert_array_almost_equal(n_eff_array, desired)
コード例 #3
0
ファイル: test_metrics.py プロジェクト: shitou333111/brainx
 def test_nodal_efficiency_disconn(self):
     self.g.remove_edge(2, 3)
     # Now all nodes still have at least one edge, but not all nodes are
     # reachable from all others.
     n_eff_array = metrics.nodal_efficiency(self.g)
     # Distances for all node pairs:
     # 0-1: 1    1-2: 1    2-3: Inf  3-4: 1
     # 0-2: 1    1-3: Inf  2-4: Inf
     # 0-3: Inf  1-4: Inf
     # 0-4: Inf
     desired = (1.0 / (self.n_nodes - 1) * np.array([
         1 + 1 + 1 / np.inf + 1 / np.inf, 1 + 1 + 1 / np.inf + 1 / np.inf,
         1 + 1 + 1 / np.inf + 1 / np.inf, 1 / np.inf + 1 / np.inf +
         1 / np.inf + 1, 1 / np.inf + 1 / np.inf + 1 / np.inf + 1
     ]))
     npt.assert_array_almost_equal(n_eff_array, desired)
コード例 #4
0
ファイル: test_metrics.py プロジェクト: EhsanTadayon/brainx
 def test_nodal_efficiency_disconn(self):
     self.g.remove_edge(2, 3)
     # Now all nodes still have at least one edge, but not all nodes are
     # reachable from all others.
     n_eff_array = metrics.nodal_efficiency(self.g)
     # Distances for all node pairs:
     # 0-1: 1    1-2: 1    2-3: Inf  3-4: 1
     # 0-2: 1    1-3: Inf  2-4: Inf
     # 0-3: Inf  1-4: Inf
     # 0-4: Inf
     desired = (1.0 / (self.n_nodes - 1) *
                np.array([1 + 1 + 1 / np.inf + 1 / np.inf,
                          1 + 1 + 1 / np.inf + 1 / np.inf,
                          1 + 1 + 1 / np.inf + 1 / np.inf,
                          1 / np.inf + 1 / np.inf + 1 / np.inf + 1,
                          1 / np.inf + 1 / np.inf + 1 / np.inf + 1]))
     npt.assert_array_almost_equal(n_eff_array, desired)