This file is indexed.

/usr/lib/python2.7/dist-packages/networkx/algorithms/centrality/tests/test_degree_centrality.py is in python-networkx 1.8.1-0ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
"""
    Unit tests for degree centrality.
"""

from nose.tools import *

import networkx as nx


class TestDegreeCentrality:
    def __init__(self):

        self.K = nx.krackhardt_kite_graph()
        self.P3 = nx.path_graph(3)
        self.K5 = nx.complete_graph(5)

        F = nx.Graph() # Florentine families
        F.add_edge('Acciaiuoli','Medici')
        F.add_edge('Castellani','Peruzzi')
        F.add_edge('Castellani','Strozzi')
        F.add_edge('Castellani','Barbadori')
        F.add_edge('Medici','Barbadori')
        F.add_edge('Medici','Ridolfi')
        F.add_edge('Medici','Tornabuoni')
        F.add_edge('Medici','Albizzi')
        F.add_edge('Medici','Salviati')
        F.add_edge('Salviati','Pazzi')
        F.add_edge('Peruzzi','Strozzi')
        F.add_edge('Peruzzi','Bischeri')
        F.add_edge('Strozzi','Ridolfi')
        F.add_edge('Strozzi','Bischeri')
        F.add_edge('Ridolfi','Tornabuoni')
        F.add_edge('Tornabuoni','Guadagni')
        F.add_edge('Albizzi','Ginori')
        F.add_edge('Albizzi','Guadagni')
        F.add_edge('Bischeri','Guadagni')
        F.add_edge('Guadagni','Lamberteschi')    
        self.F = F

        G = nx.DiGraph()
        G.add_edge(0,5)
        G.add_edge(1,5)
        G.add_edge(2,5)
        G.add_edge(3,5)
        G.add_edge(4,5)
        G.add_edge(5,6)
        G.add_edge(5,7)
        G.add_edge(5,8)
        self.G = G

    def test_degree_centrality_1(self):
        d = nx.degree_centrality(self.K5)
        exact = dict(zip(range(5), [1]*5))
        for n,dc in d.items():
            assert_almost_equal(exact[n], dc)

    def test_degree_centrality_2(self):
        d = nx.degree_centrality(self.P3)
        exact = {0:0.5, 1:1, 2:0.5}
        for n,dc in d.items():
            assert_almost_equal(exact[n], dc)

    def test_degree_centrality_3(self):
        d = nx.degree_centrality(self.K)
        exact = {0:.444, 1:.444, 2:.333, 3:.667, 4:.333,
                 5:.556, 6:.556, 7:.333, 8:.222, 9:.111}
        for n,dc in d.items():
            assert_almost_equal(exact[n], float("%5.3f" % dc))

    def test_degree_centrality_4(self):
        d = nx.degree_centrality(self.F)
        names = sorted(self.F.nodes())
        dcs = [0.071, 0.214, 0.143, 0.214, 0.214, 0.071, 0.286, 
               0.071, 0.429, 0.071, 0.214, 0.214, 0.143, 0.286, 0.214]
        exact = dict(zip(names, dcs))
        for n,dc in d.items():
            assert_almost_equal(exact[n], float("%5.3f" % dc))

    def test_indegree_centrality(self):
        d = nx.in_degree_centrality(self.G)
        exact = {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 
                 5: 0.625, 6: 0.125, 7: 0.125, 8: 0.125}
        for n,dc in d.items():
            assert_almost_equal(exact[n], dc)

    def test_outdegree_centrality(self):
        d = nx.out_degree_centrality(self.G)
        exact = {0: 0.125, 1: 0.125, 2: 0.125, 3: 0.125,    
                 4: 0.125, 5: 0.375, 6: 0.0, 7: 0.0, 8: 0.0}
        for n,dc in d.items():
            assert_almost_equal(exact[n], dc)