File: test_special.py

package info (click to toggle)
python-networkx 1.11-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 5,856 kB
  • sloc: python: 59,463; makefile: 159
file content (121 lines) | stat: -rw-r--r-- 3,728 bytes parent folder | download | duplicates (2)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/env python
from nose.tools import *
import networkx as nx
from test_graph import TestGraph
from test_digraph import TestDiGraph
from test_multigraph import TestMultiGraph
from test_multidigraph import TestMultiDiGraph
try:  # python 2.7+
    from collections import OrderedDict
except ImportError:  # python 2.6
    try:
        from ordereddict import OrderedDict
    except ImportError:
        from nose import SkipTest
        raise SkipTest('ordereddict not available')


class SpecialGraphTester(TestGraph):
    def setUp(self):
        TestGraph.setUp(self)
        self.Graph=nx.Graph

class OrderedGraphTester(TestGraph):
    def setUp(self):
        TestGraph.setUp(self)
        class MyGraph(nx.Graph):
            node_dict_factory = OrderedDict
            adjlist_dict_factory = OrderedDict
            edge_attr_dict_factory = OrderedDict
        self.Graph=MyGraph

class ThinGraphTester(TestGraph):
    def setUp(self):
        all_edge_dict = {'weight' : 1}
        class MyGraph(nx.Graph):
            edge_attr_dict_factory = lambda : all_edge_dict
        self.Graph=MyGraph
        # build dict-of-dict-of-dict K3
        ed1,ed2,ed3 = (all_edge_dict,all_edge_dict,all_edge_dict)
        self.k3adj={0: {1: ed1, 2: ed2},
                    1: {0: ed1, 2: ed3},
                    2: {0: ed2, 1: ed3}}
        self.k3edges=[(0, 1), (0, 2), (1, 2)]
        self.k3nodes=[0, 1, 2]
        self.K3=self.Graph()
        self.K3.adj=self.K3.edge=self.k3adj
        self.K3.node={}
        self.K3.node[0]={}
        self.K3.node[1]={}
        self.K3.node[2]={}




class SpecialDiGraphTester(TestDiGraph):
    def setUp(self):
        TestDiGraph.setUp(self)
        self.Graph=nx.DiGraph

class OrderedDiGraphTester(TestDiGraph):
    def setUp(self):
        TestGraph.setUp(self)
        class MyGraph(nx.DiGraph):
            node_dict_factory = OrderedDict
            adjlist_dict_factory = OrderedDict
            edge_attr_dict_factory = OrderedDict
        self.Graph=MyGraph

class ThinDiGraphTester(TestDiGraph):
    def setUp(self):
        all_edge_dict = {'weight' : 1}
        class MyGraph(nx.DiGraph):
            edge_attr_dict_factory = lambda : all_edge_dict
        self.Graph=MyGraph
        # build dict-of-dict-of-dict K3
        ed1,ed2,ed3 = (all_edge_dict,all_edge_dict,all_edge_dict)
        self.k3adj={0: {1: ed1, 2: ed2},
                    1: {0: ed1, 2: ed3},
                    2: {0: ed2, 1: ed3}}
        self.k3edges=[(0, 1), (0, 2), (1, 2)]
        self.k3nodes=[0, 1, 2]
        self.K3=self.Graph()
        self.K3.adj=self.K3.edge=self.k3adj
        self.K3.node={}
        self.K3.node[0]={}
        self.K3.node[1]={}
        self.K3.node[2]={}



class SpecialMultiGraphTester(TestMultiGraph):
    def setUp(self):
        TestMultiGraph.setUp(self)
        self.Graph=nx.MultiGraph

class OrderedMultiGraphTester(TestMultiGraph):
    def setUp(self):
        TestMultiGraph.setUp(self)
        class MyGraph(nx.MultiGraph):
            node_dict_factory = OrderedDict
            adjlist_dict_factory = OrderedDict
            edge_key_dict_factory = OrderedDict
            edge_attr_dict_factory = OrderedDict
        self.Graph=MyGraph


class SpecialMultiDiGraphTester(TestMultiDiGraph):
    def setUp(self):
        TestMultiDiGraph.setUp(self)
        self.Graph=nx.MultiDiGraph

class OrderedMultiDiGraphTester(TestMultiDiGraph):
    def setUp(self):
        TestMultiDiGraph.setUp(self)
        class MyGraph(nx.MultiDiGraph):
            node_dict_factory = OrderedDict
            adjlist_dict_factory = OrderedDict
            edge_key_dict_factory = OrderedDict
            edge_attr_dict_factory = OrderedDict
        self.Graph=MyGraph