File: test_atlas.py

package info (click to toggle)
python-networkx 1.9%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,052 kB
  • ctags: 3,986
  • sloc: python: 52,132; makefile: 176
file content (62 lines) | stat: -rw-r--r-- 1,923 bytes parent folder | download | duplicates (3)
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
from nose.tools import *
from nose import SkipTest

class TestAtlas(object):
    @classmethod
    def setupClass(cls):
        global atlas
        import platform
        if platform.python_implementation()=='Jython':
            raise SkipTest('graph atlas not available under Jython.')
        import networkx.generators.atlas as atlas

    def setUp(self):
        self.GAG=atlas.graph_atlas_g()

    def test_sizes(self):
        G=self.GAG[0]
        assert_equal(G.number_of_nodes(),0)
        assert_equal(G.number_of_edges(),0)

        G=self.GAG[7]
        assert_equal(G.number_of_nodes(),3)
        assert_equal(G.number_of_edges(),3)

    def test_names(self):
        i=0
        for g in self.GAG:
            name=g.name
            assert_equal(int(name[1:]),i)
            i+=1

    def test_monotone_nodes(self):
        # check for monotone increasing number of nodes
        previous=self.GAG[0]
        for g in self.GAG:
            assert_false(len(g)-len(previous) > 1)
            previous=g.copy()

    def test_monotone_nodes(self):
        # check for monotone increasing number of edges
        # (for fixed number of nodes)
        previous=self.GAG[0]
        for g in self.GAG:
            if len(g)==len(previous):             
                assert_false(g.size()-previous.size() > 1)
            previous=g.copy()

    def test_monotone_degree_sequence(self):
        # check for monotone increasing degree sequence
        # (for fixed number f nodes and edges)
        # note that 111223 < 112222
        previous=self.GAG[0]
        for g in self.GAG:
            if len(g)==0: 
                continue
            if len(g)==len(previous) & g.size()==previous.size():
                deg_seq=sorted(g.degree().values())
                previous_deg_seq=sorted(previous.degree().values())
                assert_true(previous_deg_seq < deg_seq)
                previous=g.copy()