Python networkx.load_centrality() Examples

The following are 30 code examples of networkx.load_centrality(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module networkx , or try the search function .
Example #1
Source File: test_load_centrality.py    From Carnets with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_florentine_families_load(self):
        G = self.F
        c = nx.load_centrality(G)
        d = {'Acciaiuoli':    0.000,
             'Albizzi':       0.211,
             'Barbadori':     0.093,
             'Bischeri':      0.104,
             'Castellani':    0.055,
             'Ginori':        0.000,
             'Guadagni':      0.251,
             'Lamberteschi':  0.000,
             'Medici':        0.522,
             'Pazzi':         0.000,
             'Peruzzi':       0.022,
             'Ridolfi':       0.117,
             'Salviati':      0.143,
             'Strozzi':       0.106,
             'Tornabuoni':    0.090}
        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3) 
Example #2
Source File: test_load_centrality.py    From aws-kube-codesuite with Apache License 2.0 6 votes vote down vote up
def test_unnormalized_florentine_families_load(self):
        G = self.F
        c = nx.load_centrality(G, normalized=False)

        d = {'Acciaiuoli':  0.000,
             'Albizzi':    38.333,
             'Barbadori':  17.000,
             'Bischeri':   19.000,
             'Castellani': 10.000,
             'Ginori':     0.000,
             'Guadagni':   45.667,
             'Lamberteschi': 0.000,
             'Medici':     95.000,
             'Pazzi':      0.000,
             'Peruzzi':    4.000,
             'Ridolfi':    21.333,
             'Salviati':   26.000,
             'Strozzi':    19.333,
             'Tornabuoni': 16.333}
        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3) 
Example #3
Source File: test_load_centrality.py    From aws-kube-codesuite with Apache License 2.0 6 votes vote down vote up
def test_unnormalized_krackhardt_load(self):
        G = self.K
        c = nx.load_centrality(G, normalized=False)
        d = {0: 1.667,
             1: 1.667,
             2: 0.000,
             3: 7.333,
             4: 0.000,
             5: 16.667,
             6: 16.667,
             7: 28.000,
             8: 16.000,
             9: 0.000}

        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3) 
Example #4
Source File: test_load_centrality.py    From aws-kube-codesuite with Apache License 2.0 6 votes vote down vote up
def test_florentine_families_load(self):
        G = self.F
        c = nx.load_centrality(G)
        d = {'Acciaiuoli':    0.000,
             'Albizzi':       0.211,
             'Barbadori':     0.093,
             'Bischeri':      0.104,
             'Castellani':    0.055,
             'Ginori':        0.000,
             'Guadagni':      0.251,
             'Lamberteschi':  0.000,
             'Medici':        0.522,
             'Pazzi':         0.000,
             'Peruzzi':       0.022,
             'Ridolfi':       0.117,
             'Salviati':      0.143,
             'Strozzi':       0.106,
             'Tornabuoni':    0.090}
        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3) 
Example #5
Source File: test_load_centrality.py    From Carnets with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_unnormalized_florentine_families_load(self):
        G = self.F
        c = nx.load_centrality(G, normalized=False)

        d = {'Acciaiuoli':  0.000,
             'Albizzi':    38.333,
             'Barbadori':  17.000,
             'Bischeri':   19.000,
             'Castellani': 10.000,
             'Ginori':     0.000,
             'Guadagni':   45.667,
             'Lamberteschi': 0.000,
             'Medici':     95.000,
             'Pazzi':      0.000,
             'Peruzzi':    4.000,
             'Ridolfi':    21.333,
             'Salviati':   26.000,
             'Strozzi':    19.333,
             'Tornabuoni': 16.333}
        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3) 
Example #6
Source File: test_load_centrality.py    From Carnets with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_unnormalized_krackhardt_load(self):
        G = self.K
        c = nx.load_centrality(G, normalized=False)
        d = {0: 1.667,
             1: 1.667,
             2: 0.000,
             3: 7.333,
             4: 0.000,
             5: 16.667,
             6: 16.667,
             7: 28.000,
             8: 16.000,
             9: 0.000}

        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3) 
Example #7
Source File: test_load_centrality.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 6 votes vote down vote up
def test_unnormalized_florentine_families_load(self):
        G=self.F
        c=nx.load_centrality(G,normalized=False)

        d={'Acciaiuoli':  0.000,
           'Albizzi':    38.333, 
           'Barbadori':  17.000,
           'Bischeri':   19.000,
           'Castellani': 10.000,
           'Ginori':     0.000,
           'Guadagni':   45.667,
           'Lamberteschi': 0.000,
           'Medici':     95.000,
           'Pazzi':      0.000,
           'Peruzzi':    4.000,
           'Ridolfi':    21.333,
           'Salviati':   26.000,
           'Strozzi':    19.333,
           'Tornabuoni': 16.333}
        for n in sorted(G):
            assert_almost_equal(c[n],d[n],places=3) 
Example #8
Source File: test_load_centrality.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 6 votes vote down vote up
def test_unnormalized_krackhardt_load(self):
        G=self.K
        c=nx.load_centrality(G,normalized=False)
        d={0: 1.667,
           1: 1.667,
           2: 0.000,
           3: 7.333,
           4: 0.000,
           5: 16.667,
           6: 16.667,
           7: 28.000,
           8: 16.000,
           9: 0.000}

        for n in sorted(G):
            assert_almost_equal(c[n],d[n],places=3) 
Example #9
Source File: test_load_centrality.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 6 votes vote down vote up
def test_florentine_families_load(self):
        G=self.F
        c=nx.load_centrality(G)
        d={'Acciaiuoli':    0.000,
           'Albizzi':       0.211,
           'Barbadori':     0.093,
           'Bischeri':      0.104,
           'Castellani':    0.055,
           'Ginori':        0.000,
           'Guadagni':      0.251,
           'Lamberteschi':  0.000,
           'Medici':        0.522,
           'Pazzi':         0.000,
           'Peruzzi':       0.022,
           'Ridolfi':       0.117,
           'Salviati':      0.143,
           'Strozzi':       0.106,
           'Tornabuoni':    0.090}
        for n in sorted(G):
            assert_almost_equal(c[n],d[n],places=3) 
Example #10
Source File: test_load_centrality.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes vote down vote up
def test_p2_load(self):
        G=nx.path_graph(2)
        c=nx.load_centrality(G)
        d={0: 0.000,
           1: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n],d[n],places=3) 
Example #11
Source File: test_load_centrality.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes vote down vote up
def test_weighted_load(self):
        b=nx.load_centrality(self.G,weight='weight',normalized=False)
        for n in sorted(self.G):
            assert_equal(b[n],self.exact_weighted[n]) 
Example #12
Source File: test_load_centrality.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes vote down vote up
def test_k5_load(self):
        G=self.K5
        c=nx.load_centrality(G)
        d={0: 0.000,
           1: 0.000,
           2: 0.000,
           3: 0.000,
           4: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n],d[n],places=3) 
Example #13
Source File: test_load_centrality.py    From aws-kube-codesuite with Apache License 2.0 5 votes vote down vote up
def test_unnormalized_p3_load(self):
        G = self.P3
        c = nx.load_centrality(G, normalized=False)
        d = {0: 0.000,
             1: 2.000,
             2: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3) 
Example #14
Source File: test_load_centrality.py    From aws-kube-codesuite with Apache License 2.0 5 votes vote down vote up
def test_unnormalized_k5_load(self):
        G = self.K5
        c = nx.load_centrality(G, normalized=False)
        d = {0: 0.000,
             1: 0.000,
             2: 0.000,
             3: 0.000,
             4: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3) 
Example #15
Source File: test_load_centrality.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes vote down vote up
def test_p3_load(self):
        G=self.P3
        c=nx.load_centrality(G)
        d={0: 0.000,
           1: 1.000,
           2: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n],d[n],places=3)
        c=nx.load_centrality(G,v=1)
        assert_almost_equal(c,1.0)
        c=nx.load_centrality(G,v=1,normalized=True)
        assert_almost_equal(c,1.0) 
Example #16
Source File: test_load_centrality.py    From aws-kube-codesuite with Apache License 2.0 5 votes vote down vote up
def test_p2_load(self):
        G = nx.path_graph(2)
        c = nx.load_centrality(G)
        d = {0: 0.000,
             1: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3) 
Example #17
Source File: test_load_centrality.py    From aws-kube-codesuite with Apache License 2.0 5 votes vote down vote up
def test_p3_load(self):
        G = self.P3
        c = nx.load_centrality(G)
        d = {0: 0.000,
             1: 1.000,
             2: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3)
        c = nx.load_centrality(G, v=1)
        assert_almost_equal(c, 1.0)
        c = nx.load_centrality(G, v=1, normalized=True)
        assert_almost_equal(c, 1.0) 
Example #18
Source File: test_load_centrality.py    From aws-kube-codesuite with Apache License 2.0 5 votes vote down vote up
def test_k5_load(self):
        G = self.K5
        c = nx.load_centrality(G)
        d = {0: 0.000,
             1: 0.000,
             2: 0.000,
             3: 0.000,
             4: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3) 
Example #19
Source File: test_load_centrality.py    From aws-kube-codesuite with Apache License 2.0 5 votes vote down vote up
def test_weighted_load(self):
        b = nx.load_centrality(self.G, weight='weight', normalized=False)
        for n in sorted(self.G):
            assert_equal(b[n], self.exact_weighted[n]) 
Example #20
Source File: test_load_centrality.py    From aws-kube-codesuite with Apache License 2.0 5 votes vote down vote up
def test_not_strongly_connected(self):
        b = nx.load_centrality(self.D)
        result = {0: 5. / 12,
                  1: 1. / 4,
                  2: 1. / 12,
                  3: 1. / 4,
                  4: 0.000}
        for n in sorted(self.D):
            assert_almost_equal(result[n], b[n], places=3)
            assert_almost_equal(result[n], nx.load_centrality(self.D, n), places=3) 
Example #21
Source File: test_load_centrality.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes vote down vote up
def test_unnormalized_p3_load(self):
        G=self.P3
        c=nx.load_centrality(G,normalized=False)
        d={0: 0.000,
           1: 2.000,
           2: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n],d[n],places=3) 
Example #22
Source File: test_load_centrality.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_unnormalized_p3_load(self):
        G = self.P3
        c = nx.load_centrality(G, normalized=False)
        d = {0: 0.000,
             1: 2.000,
             2: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3) 
Example #23
Source File: test_load_centrality.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_unnormalized_k5_load(self):
        G = self.K5
        c = nx.load_centrality(G, normalized=False)
        d = {0: 0.000,
             1: 0.000,
             2: 0.000,
             3: 0.000,
             4: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3) 
Example #24
Source File: test_load_centrality.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes vote down vote up
def test_not_strongly_connected(self):
        b = nx.load_centrality(self.D)
        result = {0: 5./12,
                  1: 1./4,
                  2: 1./12,
                  3: 1./4,
                  4: 0.000}
        for n in sorted(self.D):
            assert_almost_equal(result[n], b[n], places=3)
            assert_almost_equal(result[n], nx.load_centrality(self.D, n), places=3) 
Example #25
Source File: test_load_centrality.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_p2_load(self):
        G = nx.path_graph(2)
        c = nx.load_centrality(G)
        d = {0: 0.000,
             1: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3) 
Example #26
Source File: test_load_centrality.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_p3_load(self):
        G = self.P3
        c = nx.load_centrality(G)
        d = {0: 0.000,
             1: 1.000,
             2: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3)
        c = nx.load_centrality(G, v=1)
        assert_almost_equal(c, 1.0)
        c = nx.load_centrality(G, v=1, normalized=True)
        assert_almost_equal(c, 1.0) 
Example #27
Source File: test_load_centrality.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_k5_load(self):
        G = self.K5
        c = nx.load_centrality(G)
        d = {0: 0.000,
             1: 0.000,
             2: 0.000,
             3: 0.000,
             4: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n], d[n], places=3) 
Example #28
Source File: test_load_centrality.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_weighted_load(self):
        b = nx.load_centrality(self.G, weight='weight', normalized=False)
        for n in sorted(self.G):
            assert_equal(b[n], self.exact_weighted[n]) 
Example #29
Source File: test_load_centrality.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_not_strongly_connected(self):
        b = nx.load_centrality(self.D)
        result = {0: 5. / 12,
                  1: 1. / 4,
                  2: 1. / 12,
                  3: 1. / 4,
                  4: 0.000}
        for n in sorted(self.D):
            assert_almost_equal(result[n], b[n], places=3)
            assert_almost_equal(result[n], nx.load_centrality(self.D, n), places=3) 
Example #30
Source File: test_load_centrality.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes vote down vote up
def test_unnormalized_k5_load(self):
        G=self.K5
        c=nx.load_centrality(G,normalized=False)
        d={0: 0.000,
           1: 0.000,
           2: 0.000,
           3: 0.000,
           4: 0.000}
        for n in sorted(G):
            assert_almost_equal(c[n],d[n],places=3)