~ubuntu-branches/ubuntu/trusty/python-networkx/trusty

« back to all changes in this revision

Viewing changes to networkx/generators/tests/bipartite.txt-

  • Committer: Bazaar Package Importer
  • Author(s): Sandro Tosi
  • Date: 2010-12-10 23:50:27 UTC
  • mfrom: (1.2.4 upstream) (5.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20101210235027-b2supdwo0ad39d3s
Tags: 1.3-1
* New upstream release
* debian/patches/changeset_r1745.diff
  - dropped, available in upstream release
* debian/patches/10_doc_relocation
  - refreshed patch for new upstream code
* debian/control
  - upstream code is now compatible with 2.6 or later only
  - bump Standards-Version to 3.9.1 (no changes needed)
* debian/{control, rules}
  - run unittests at build time, b-d on python-nose added
* debian/copyright
  - removed reference to /usr/share/common-licenses/BSD
* Create a -doc package ; thanks to Yaroslav Halchenko for the report;
  Closes: #567369
  - (d/control) define a new binary package, and add depends on sphinx (>= 1)
  - (d/rules) build documentation, install it into the new -doc package
  - (d/patches/30_use_local_objects.inv) use local copy of remote objects.inv
* debian/{control, rules}
  - moved to dh7 and "reduced" rules file
* debian/rules
  - refer to built code when building doc
* debian/python-networkx-doc.doc-base
  - added doc-base information
* debian/patches/40_add_networkxcss
  - added as patch, since networkx.css is missing from the tarball, but needed
    to display properly HTML documentation
* debian/patches/50_boundary-test-fix.patch
  - upstream patch to restrict node boundary test cases to valid range
* debian/patches/60_remove_svn_refs.diff
  - upstream patch to remove references to old SVN repository (now Mercurial)
* debian/patches/70_set_matplotlib_ps_backend.patch
  - set matplotlib backend to 'PS', so a DISPLAY it's not required and the
    tests can be run in a "reduced" environment

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Generators - Bipartite
2
 
----------------------
3
 
 
4
 
>>> from networkx import *
5
 
>>> from networkx.generators.bipartite import *
6
 
 
7
 
Configuration Model
8
 
-------------------
9
 
 
10
 
>>> aseq=[3,3,3,3]
11
 
>>> bseq=[2,2,2,2,2] 
12
 
>>> G=bipartite_configuration_model(aseq,bseq)
13
 
Traceback (most recent call last):
14
 
...
15
 
NetworkXError: invalid degree sequences, sum(aseq)!=sum(bseq),12,10
16
 
 
17
 
>>> aseq=[3,3,3,3]
18
 
>>> bseq=[2,2,2,2,2,2] 
19
 
>>> G=bipartite_configuration_model(aseq,bseq)
20
 
>>> sorted(G.degree())
21
 
[2, 2, 2, 2, 2, 2, 3, 3, 3, 3]
22
 
 
23
 
>>> aseq=[2,2,2,2,2,2] 
24
 
>>> bseq=[3,3,3,3]
25
 
>>> G=bipartite_configuration_model(aseq,bseq)
26
 
>>> sorted(G.degree())
27
 
[2, 2, 2, 2, 2, 2, 3, 3, 3, 3]
28
 
 
29
 
 
30
 
>>> aseq=[2,2,2,1,1,1] 
31
 
>>> bseq=[3,3,3]
32
 
>>> G=bipartite_configuration_model(aseq,bseq)
33
 
>>> sorted(G.degree())
34
 
[1, 1, 1, 2, 2, 2, 3, 3, 3]
35
 
 
36
 
>>> GU=project(G,range(len(aseq)))
37
 
>>> GU.number_of_nodes()
38
 
6
39
 
 
40
 
>>> GD=project(G,range(len(aseq),len(aseq)+len(bseq)))
41
 
>>> GD.number_of_nodes()
42
 
3
43
 
 
44
 
 
45
 
Havel-Hakimi Graph
46
 
------------------
47
 
 
48
 
>>> aseq=[3,3,3,3]
49
 
>>> bseq=[2,2,2,2,2] 
50
 
>>> G=bipartite_havel_hakimi_graph(aseq,bseq)
51
 
Traceback (most recent call last):
52
 
...
53
 
NetworkXError: invalid degree sequences, sum(aseq)!=sum(bseq),12,10
54
 
 
55
 
>>> bseq=[2,2,2,2,2,2] 
56
 
>>> G=bipartite_havel_hakimi_graph(aseq,bseq)
57
 
>>> sorted(G.degree())
58
 
[2, 2, 2, 2, 2, 2, 3, 3, 3, 3]
59
 
 
60
 
 
61
 
>>> aseq=[2,2,2,2,2,2] 
62
 
>>> bseq=[3,3,3,3]
63
 
>>> G=bipartite_havel_hakimi_graph(aseq,bseq)
64
 
>>> sorted(G.degree())
65
 
[2, 2, 2, 2, 2, 2, 3, 3, 3, 3]
66
 
 
67
 
 
68
 
 
69
 
>>> GU=project(G,range(len(aseq)))
70
 
>>> GU.number_of_nodes()
71
 
6
72
 
 
73
 
>>> GD=project(G,range(len(aseq),len(aseq)+len(bseq)))
74
 
>>> GD.number_of_nodes()
75
 
4
76
 
 
77
 
 
78
 
 
79
 
Reverse Havel-Hakimi Graph
80
 
--------------------------
81
 
 
82
 
>>> aseq=[3,3,3,3]
83
 
>>> bseq=[2,2,2,2,2] 
84
 
>>> G=bipartite_reverse_havel_hakimi_graph(aseq,bseq)
85
 
Traceback (most recent call last):
86
 
...
87
 
NetworkXError: invalid degree sequences, sum(aseq)!=sum(bseq),12,10
88
 
 
89
 
>>> bseq=[2,2,2,2,2,2] 
90
 
>>> G=bipartite_reverse_havel_hakimi_graph(aseq,bseq)
91
 
>>> sorted(G.degree())
92
 
[2, 2, 2, 2, 2, 2, 3, 3, 3, 3]
93
 
 
94
 
 
95
 
>>> aseq=[2,2,2,2,2,2] 
96
 
>>> bseq=[3,3,3,3]
97
 
>>> G=bipartite_reverse_havel_hakimi_graph(aseq,bseq)
98
 
>>> sorted(G.degree())
99
 
[2, 2, 2, 2, 2, 2, 3, 3, 3, 3]
100
 
 
101
 
 
102
 
>>> aseq=[2,2,2,1,1,1] 
103
 
>>> bseq=[3,3,3]
104
 
>>> G=bipartite_reverse_havel_hakimi_graph(aseq,bseq)
105
 
>>> sorted(G.degree())
106
 
[1, 1, 1, 2, 2, 2, 3, 3, 3]
107
 
 
108
 
 
109
 
>>> GU=project(G,range(len(aseq)))
110
 
>>> GU.number_of_nodes()
111
 
6
112
 
 
113
 
>>> GD=project(G,range(len(aseq),len(aseq)+len(bseq)))
114
 
>>> GD.number_of_nodes()
115
 
3
116
 
 
117
 
 
118
 
 
119
 
Alternating Havel-Hakimi Graph
120
 
------------------------------
121
 
 
122
 
>>> aseq=[3,3,3,3]
123
 
>>> bseq=[2,2,2,2,2] 
124
 
>>> G=bipartite_alternating_havel_hakimi_graph(aseq,bseq)
125
 
Traceback (most recent call last):
126
 
...
127
 
NetworkXError: invalid degree sequences, sum(aseq)!=sum(bseq),12,10
128
 
 
129
 
>>> bseq=[2,2,2,2,2,2] 
130
 
>>> G=bipartite_alternating_havel_hakimi_graph(aseq,bseq)
131
 
>>> sorted(G.degree())
132
 
[2, 2, 2, 2, 2, 2, 3, 3, 3, 3]
133
 
 
134
 
>>> aseq=[2,2,2,2,2,2] 
135
 
>>> bseq=[3,3,3,3]
136
 
>>> G=bipartite_alternating_havel_hakimi_graph(aseq,bseq)
137
 
>>> sorted(G.degree())
138
 
[2, 2, 2, 2, 2, 2, 3, 3, 3, 3]
139
 
 
140
 
 
141
 
>>> aseq=[2,2,2,1,1,1] 
142
 
>>> bseq=[3,3,3]
143
 
>>> G=bipartite_alternating_havel_hakimi_graph(aseq,bseq)
144
 
>>> sorted(G.degree())
145
 
[1, 1, 1, 2, 2, 2, 3, 3, 3]
146
 
 
147
 
 
148
 
>>> GU=project(G,range(len(aseq)))
149
 
>>> GU.number_of_nodes()
150
 
6
151
 
 
152
 
>>> GD=project(G,range(len(aseq),len(aseq)+len(bseq)))
153
 
>>> GD.number_of_nodes()
154
 
3
155
 
 
156
 
 
157
 
Preferential Attachment
158
 
-----------------------
159
 
 
160
 
>>> aseq=[3,2,1,1]
161
 
>>> G=bipartite_preferential_attachment_graph(aseq,0.5)
162
 
 
163
 
 
164
 
Random Regular Bipartite
165
 
------------------------
166
 
FIXME: test this somehow
167
 
G=bipartite_random_regular_graph(2,12)
168
 
G.degree()
169
 
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]
170
 
is_bipartite(G)
171
 
True
172
 
 
173
 
Coloring and bipartite sets
174
 
---------------------------
175
 
>>> G=complete_bipartite_graph(2,2)
176
 
>>> is_bipartite(G)
177
 
True
178
 
>>> A,B=bipartite_sets(G)
179
 
>>> A
180
 
[0, 1]
181
 
>>> B
182
 
[2, 3]
183
 
>>> bipartite_color(G)
184
 
{0: 1, 1: 1, 2: 0, 3: 0}
185
 
 
186
 
>>> G=path_graph(10)
187
 
>>> is_bipartite(G)
188
 
True
189
 
>>> A,B=bipartite_sets(G)
190
 
>>> A
191
 
[0, 2, 4, 6, 8]
192
 
>>> B
193
 
[1, 3, 5, 7, 9]
194
 
 
195
 
>>> G=cycle_graph(5)
196
 
>>> is_bipartite(G)
197
 
False
198
 
 
199
 
>>> G=cycle_graph(6)
200
 
>>> is_bipartite(G)
201
 
True
202
 
 
203
 
>>> G=Graph({0: {7: None},1: {7: None},2: {6: None},3: {6: None},4:{5: None},5: {4: None, 7: None},6: {2: None, 3: None, 7: None},7:{0: None, 1: None, 5: None, 6: None}})
204
 
>>> is_bipartite(G)
205
 
True