This file is indexed.

/usr/lib/python3/dist-packages/networkx/algorithms/components/tests/test_subgraph_copies.py is in python3-networkx 1.11-1ubuntu2.

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
""" Tests for subgraphs attributes
"""
from copy import deepcopy
from nose.tools import assert_equal
import networkx as nx

class TestSubgraphAttributesDicts:

    def setUp(self):
        self.undirected = [
            nx.connected_component_subgraphs,
            nx.biconnected_component_subgraphs,
        ]
        self.directed = [
            nx.weakly_connected_component_subgraphs,
            nx.strongly_connected_component_subgraphs,
            nx.attracting_component_subgraphs,
        ]
        self.subgraph_funcs = self.undirected + self.directed
        
        self.D = nx.DiGraph()
        self.D.add_edge(1, 2, eattr='red')
        self.D.add_edge(2, 1, eattr='red')
        self.D.node[1]['nattr'] = 'blue'
        self.D.graph['gattr'] = 'green'

        self.G = nx.Graph()
        self.G.add_edge(1, 2, eattr='red')
        self.G.node[1]['nattr'] = 'blue'
        self.G.graph['gattr'] = 'green'

    def test_subgraphs_default_copy_behavior(self):
        # Test the default behavior of subgraph functions 
        # For the moment (1.10) the default is to copy
        for subgraph_func in self.subgraph_funcs:
            G = deepcopy(self.G if subgraph_func in self.undirected else self.D)
            SG = list(subgraph_func(G))[0]
            assert_equal(SG[1][2]['eattr'], 'red')
            assert_equal(SG.node[1]['nattr'], 'blue')
            assert_equal(SG.graph['gattr'], 'green')
            SG[1][2]['eattr'] = 'foo'
            assert_equal(G[1][2]['eattr'], 'red')
            assert_equal(SG[1][2]['eattr'], 'foo')
            SG.node[1]['nattr'] = 'bar'
            assert_equal(G.node[1]['nattr'], 'blue')
            assert_equal(SG.node[1]['nattr'], 'bar')
            SG.graph['gattr'] = 'baz'
            assert_equal(G.graph['gattr'], 'green')
            assert_equal(SG.graph['gattr'], 'baz')

    def test_subgraphs_copy(self):
        for subgraph_func in self.subgraph_funcs:
            test_graph = self.G if subgraph_func in self.undirected else self.D
            G = deepcopy(test_graph)
            SG = list(subgraph_func(G, copy=True))[0]
            assert_equal(SG[1][2]['eattr'], 'red')
            assert_equal(SG.node[1]['nattr'], 'blue')
            assert_equal(SG.graph['gattr'], 'green')
            SG[1][2]['eattr'] = 'foo'
            assert_equal(G[1][2]['eattr'], 'red')
            assert_equal(SG[1][2]['eattr'], 'foo')
            SG.node[1]['nattr'] = 'bar'
            assert_equal(G.node[1]['nattr'], 'blue')
            assert_equal(SG.node[1]['nattr'], 'bar')
            SG.graph['gattr'] = 'baz'
            assert_equal(G.graph['gattr'], 'green')
            assert_equal(SG.graph['gattr'], 'baz')

    def test_subgraphs_no_copy(self):
        for subgraph_func in self.subgraph_funcs:
            G = deepcopy(self.G if subgraph_func in self.undirected else self.D)
            SG = list(subgraph_func(G, copy=False))[0]
            assert_equal(SG[1][2]['eattr'], 'red')
            assert_equal(SG.node[1]['nattr'], 'blue')
            assert_equal(SG.graph['gattr'], 'green')
            SG[1][2]['eattr'] = 'foo'
            assert_equal(G[1][2]['eattr'], 'foo')
            assert_equal(SG[1][2]['eattr'], 'foo')
            SG.node[1]['nattr'] = 'bar'
            assert_equal(G.node[1]['nattr'], 'bar')
            assert_equal(SG.node[1]['nattr'], 'bar')
            SG.graph['gattr'] = 'baz'
            assert_equal(G.graph['gattr'], 'baz')
            assert_equal(SG.graph['gattr'], 'baz')