Python Igraph
Python Igraph
API Documentation
April 24, 2014
Contents
Contents
1 Package igraph
1.1 Modules . . . . . . . . .
1.2 Functions . . . . . . . .
1.3 Variables . . . . . . . .
1.4 Class Vertex . . . . . . .
1.4.1 Methods . . . . .
1.4.2 Properties . . . .
1.5 Class Graph . . . . . . .
1.5.1 Methods . . . . .
1.5.2 Properties . . . .
1.6 Class VertexSeq . . . . .
1.6.1 Methods . . . . .
1.6.2 Properties . . . .
1.7 Class EdgeSeq . . . . .
1.7.1 Methods . . . . .
1.7.2 Properties . . . .
1.8 Class ARPACKOptions
1.8.1 Methods . . . . .
1.8.2 Properties . . . .
1.9 Class BFSIter . . . . . .
1.9.1 Methods . . . . .
1.9.2 Properties . . . .
1.10 Class Edge . . . . . . .
1.10.1 Methods . . . . .
1.10.2 Properties . . . .
1.11 Class GraphBase . . . .
1.11.1 Methods . . . . .
1.11.2 Properties . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
2
2
4
5
6
6
11
11
13
84
85
86
92
92
94
97
97
98
98
99
99
99
99
100
102
103
104
215
2 Module igraph._igraph
2.1 Functions . . . . . . .
2.2 Variables . . . . . . .
2.3 Class InternalError . .
2.3.1 Methods . . . .
2.3.2 Properties . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
216
216
218
220
220
220
.
.
.
.
.
CONTENTS
CONTENTS
3 Package igraph.app
221
3.1 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
3.2 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
4 Module igraph.app.shell
4.1 Functions . . . . . . . . . . . .
4.2 Variables . . . . . . . . . . . .
4.3 Class TerminalController . . . .
4.3.1 Methods . . . . . . . . .
4.3.2 Class Variables . . . . .
4.4 Class ProgressBar . . . . . . .
4.4.1 Methods . . . . . . . . .
4.4.2 Class Variables . . . . .
4.4.3 Instance Variables . . .
4.5 Class Shell . . . . . . . . . . . .
4.5.1 Methods . . . . . . . . .
4.5.2 Properties . . . . . . . .
4.6 Class IDLEShell . . . . . . . .
4.6.1 Methods . . . . . . . . .
4.6.2 Properties . . . . . . . .
4.7 Class ConsoleProgressBarMixin
4.7.1 Methods . . . . . . . . .
4.7.2 Properties . . . . . . . .
4.8 Class IPythonShell . . . . . . .
4.8.1 Methods . . . . . . . . .
4.8.2 Properties . . . . . . . .
4.9 Class ClassicPythonShell . . . .
4.9.1 Methods . . . . . . . . .
4.9.2 Properties . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
222
222
222
222
223
223
225
225
226
226
226
226
227
227
228
228
228
229
229
229
230
230
230
231
231
5 Module igraph.clustering
5.1 Functions . . . . . . . .
5.2 Variables . . . . . . . .
5.3 Class Clustering . . . .
5.3.1 Methods . . . . .
5.3.2 Properties . . . .
5.4 Class VertexClustering .
5.4.1 Methods . . . . .
5.4.2 Properties . . . .
5.5 Class Dendrogram . . .
5.5.1 Methods . . . . .
5.5.2 Properties . . . .
5.6 Class VertexDendrogram
5.6.1 Methods . . . . .
5.6.2 Properties . . . .
5.7 Class Cover . . . . . . .
5.7.1 Methods . . . . .
5.7.2 Properties . . . .
5.8 Class VertexCover . . .
5.8.1 Methods . . . . .
5.8.2 Properties . . . .
5.9 Class CohesiveBlocks . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
232
234
236
236
237
239
239
240
245
245
246
247
248
248
249
250
251
253
253
253
256
256
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
CONTENTS
CONTENTS
5.9.1
5.9.2
Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
6 Module igraph.compat
260
6.1 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
7 Module igraph.configuration
7.1 Functions . . . . . . . . . .
7.2 Variables . . . . . . . . . .
7.3 Class Configuration . . . . .
7.3.1 Methods . . . . . . .
7.3.2 Properties . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
261
261
262
262
264
265
8 Module igraph.cut
8.1 Variables . . . .
8.2 Class Cut . . . .
8.2.1 Methods .
8.2.2 Properties
8.3 Class Flow . . . .
8.3.1 Methods .
8.3.2 Properties
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
267
267
267
269
270
270
272
273
9 Module igraph.datatypes
9.1 Variables . . . . . . . . .
9.2 Class Matrix . . . . . . .
9.2.1 Methods . . . . . .
9.2.2 Properties . . . . .
9.3 Class DyadCensus . . . .
9.3.1 Methods . . . . . .
9.3.2 Properties . . . . .
9.4 Class TriadCensus . . . .
9.4.1 Methods . . . . . .
9.4.2 Properties . . . . .
9.5 Class UniqueIdGenerator
9.5.1 Methods . . . . . .
9.5.2 Properties . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
274
274
274
275
279
279
280
281
281
282
283
283
284
285
10 Package igraph.drawing
10.1 Modules . . . . . . . . . . .
10.2 Functions . . . . . . . . . .
10.3 Class DefaultGraphDrawer
10.3.1 Methods . . . . . . .
10.3.2 Properties . . . . . .
10.4 Class BoundingBox . . . . .
10.4.1 Methods . . . . . . .
10.4.2 Properties . . . . . .
10.5 Class Point . . . . . . . . .
10.5.1 Methods . . . . . . .
10.5.2 Properties . . . . . .
10.6 Class Rectangle . . . . . . .
10.6.1 Methods . . . . . . .
10.6.2 Properties . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
286
286
288
289
290
291
291
292
292
293
293
295
295
296
300
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
CONTENTS
CONTENTS
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
306
306
306
306
306
307
307
307
308
308
309
12 Module igraph.drawing.colors
12.1 Functions . . . . . . . . . . . .
12.2 Variables . . . . . . . . . . . .
12.3 Class Palette . . . . . . . . . .
12.3.1 Methods . . . . . . . . .
12.3.2 Properties . . . . . . . .
12.4 Class GradientPalette . . . . .
12.4.1 Methods . . . . . . . . .
12.4.2 Properties . . . . . . . .
12.5 Class AdvancedGradientPalette
12.5.1 Methods . . . . . . . . .
12.5.2 Properties . . . . . . . .
12.6 Class RainbowPalette . . . . .
12.6.1 Methods . . . . . . . . .
12.6.2 Properties . . . . . . . .
12.7 Class PrecalculatedPalette . . .
12.7.1 Methods . . . . . . . . .
12.7.2 Properties . . . . . . . .
12.8 Class ClusterColoringPalette .
12.8.1 Methods . . . . . . . . .
12.8.2 Properties . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
310
310
313
313
313
316
316
317
317
317
318
318
319
320
320
320
321
321
321
322
322
13 Module igraph.drawing.coord
13.1 Variables . . . . . . . . . . . . .
13.2 Class CoordinateSystem . . . . .
13.2.1 Methods . . . . . . . . . .
13.2.2 Properties . . . . . . . . .
13.3 Class DescartesCoordinateSystem
13.3.1 Methods . . . . . . . . . .
13.3.2 Properties . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
323
323
323
323
324
324
325
325
14 Module igraph.drawing.edge
14.1 Class AbstractEdgeDrawer
14.1.1 Methods . . . . . . .
14.1.2 Properties . . . . . .
14.2 Class ArrowEdgeDrawer . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
326
326
326
328
328
.
.
.
.
.
.
.
.
.
.
.
.
CONTENTS
CONTENTS
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
329
329
329
330
330
330
331
331
332
332
332
333
333
333
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
334
334
335
336
336
337
338
338
339
340
16 Module igraph.drawing.metamagic
16.1 Class AttributeSpecification . . . .
16.1.1 Methods . . . . . . . . . . .
16.1.2 Properties . . . . . . . . . .
16.2 Class AttributeCollectorBase . . .
16.2.1 Methods . . . . . . . . . . .
16.2.2 Properties . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
341
342
342
342
343
343
344
17 Module igraph.drawing.shapes
17.1 Class ShapeDrawerDirectory
17.1.1 Methods . . . . . . . .
17.1.2 Properties . . . . . . .
17.1.3 Class Variables . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
345
345
346
347
347
18 Module igraph.drawing.text
18.1 Class TextAlignment . . . .
18.1.1 Methods . . . . . . .
18.1.2 Properties . . . . . .
18.1.3 Class Variables . . .
18.2 Class TextDrawer . . . . . .
18.2.1 Methods . . . . . . .
18.2.2 Properties . . . . . .
18.2.3 Class Variables . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
348
348
348
348
348
349
349
351
352
14.3
14.4
14.5
14.6
14.2.1 Methods . . . . . . . . .
14.2.2 Properties . . . . . . . .
Class TaperedEdgeDrawer . . .
14.3.1 Methods . . . . . . . . .
14.3.2 Properties . . . . . . . .
Class AlphaVaryingEdgeDrawer
14.4.1 Methods . . . . . . . . .
14.4.2 Properties . . . . . . . .
Class LightToDarkEdgeDrawer
14.5.1 Methods . . . . . . . . .
14.5.2 Properties . . . . . . . .
Class DarkToLightEdgeDrawer
14.6.1 Methods . . . . . . . . .
14.6.2 Properties . . . . . . . .
15 Module igraph.drawing.graph
15.1 Class DefaultGraphDrawer .
15.1.1 Methods . . . . . . . .
15.1.2 Properties . . . . . . .
15.2 Class UbiGraphDrawer . . . .
15.2.1 Methods . . . . . . . .
15.2.2 Properties . . . . . . .
15.3 Class CytoscapeGraphDrawer
15.3.1 Methods . . . . . . . .
15.3.2 Properties . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
19 Module igraph.drawing.utils
353
19.1 Class Rectangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
CONTENTS
19.1.1 Methods . .
19.1.2 Properties .
19.2 Class BoundingBox
19.2.1 Methods . .
19.2.2 Properties .
19.3 Class FakeModule
19.3.1 Methods . .
19.3.2 Properties .
19.4 Class Point . . . .
19.4.1 Methods . .
19.4.2 Properties .
CONTENTS
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
353
358
358
359
359
360
360
360
361
361
363
20 Module igraph.drawing.vertex
20.1 Class AbstractVertexDrawer . . . .
20.1.1 Methods . . . . . . . . . . .
20.1.2 Properties . . . . . . . . . .
20.2 Class AbstractCairoVertexDrawer .
20.2.1 Methods . . . . . . . . . . .
20.2.2 Properties . . . . . . . . . .
20.3 Class DefaultVertexDrawer . . . .
20.3.1 Methods . . . . . . . . . . .
20.3.2 Properties . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
364
364
364
365
365
366
366
367
367
368
21 Module igraph.layout
21.1 Variables . . . . .
21.2 Class Layout . . .
21.2.1 Methods . .
21.2.2 Properties .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
369
369
369
370
375
22 Module igraph.matching
22.1 Variables . . . . . . .
22.2 Class Matching . . . .
22.2.1 Methods . . . .
22.2.2 Properties . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
376
376
376
377
378
.
.
.
.
23 Package igraph.remote
380
23.1 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
23.2 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
24 Module igraph.remote.gephi
24.1 Class GephiConnection . . . . . . . . . .
24.1.1 Methods . . . . . . . . . . . . . .
24.1.2 Properties . . . . . . . . . . . . .
24.2 Class GephiGraphStreamingAPIFormat
24.2.1 Methods . . . . . . . . . . . . . .
24.2.2 Properties . . . . . . . . . . . . .
24.3 Class GephiGraphStreamer . . . . . . .
24.3.1 Methods . . . . . . . . . . . . . .
24.3.2 Properties . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
381
381
381
382
383
383
385
385
386
387
25 Module igraph.remote.nexus
388
25.1 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
CONTENTS
CONTENTS
.
.
.
.
.
.
.
.
.
.
393
393
396
397
398
398
399
400
401
401
403
27 Module igraph.summary
27.1 Class GraphSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.1.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.1.2 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
404
404
405
406
28 Module igraph.utils
28.1 Functions . . . . . . .
28.2 Variables . . . . . . .
28.3 Class multidict . . . .
28.3.1 Methods . . . .
28.3.2 Properties . . .
28.3.3 Class Variables
407
407
409
410
410
414
414
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Package igraph
Package igraph
IGraph library.
Version: 0.7.0
License: Copyright (C) 2006-2012 Tams Nepusz <ntamas@gmail.com> Pzmny Pter stny 1/a, 1117
Budapest, Hungary
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General
Public License as published by the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write
to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1.1
Modules
Modules
Package igraph
Functions
1.2
Package igraph
Functions
autocurve(graph, attribute=curved, default=0)
Calculates curvature values for each of the edges in the graph to make sure that multiple
edges are shown properly on a graph plot.
This function checks the multiplicity of each edge in the graph and assigns curvature values
(numbers between -1 and 1, corresponding to CCW (-1), straight (0) and CW (1) curved
edges) to them. The assigned values are either stored in an edge attribute or returned as a
list, depending on the value of the attribute argument.
Parameters
graph:
attribute: the name of the edge attribute to save the curvature values to. The
default value is curved, which is the name of the edge attribute the
default graph plotter checks to decide whether an edge should be
curved on the plot or not. If attribute is None, the result will not be
stored.
default:
the default curvature for single edges. Zero means that single edges
will be straight. If you want single edges to be curved as well, try
passing 0.5 or -0.5 here.
Return Value
the list of curvature values if attribute is None, otherwise None.
read(filename, *args, **kwds)
Loads a graph from the given filename.
This is just a convenience function, calls Graph.Read directly. All arguments are passed
unchanged to Graph.Read
Parameters
filename: the name of the file to be loaded
load(filename, *args, **kwds)
Loads a graph from the given filename.
This is just a convenience function, calls Graph.Read directly. All arguments are passed
unchanged to Graph.Read
Parameters
filename: the name of the file to be loaded
write(graph, filename, *args, **kwds)
Saves a graph to the given file.
This is just a convenience function, calls Graph.write directly. All arguments are passed
unchanged to Graph.write
Parameters
graph:
Variables
Package igraph
1.3
Variables
Name
config
ADJ_DIRECTED
ADJ_LOWER
ADJ_MAX
ADJ_MIN
ADJ_PLUS
ADJ_UNDIRECTED
ADJ_UPPER
ALL
BLISS_F
BLISS_FL
BLISS_FLM
BLISS_FM
BLISS_FS
BLISS_FSM
GET_ADJACENCY_BOTH
GET_ADJACENCY_LOWER
GET_ADJACENCY_UPPER
IN
OUT
REWIRING_SIMPLE
REWIRING_SIMPLE_LOOPS
STAR_IN
STAR_MUTUAL
STAR_OUT
Description
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
None
0
3
1
4
5
1
2
3
0
1
4
3
2
5
2
1
Value:
Value:
Value:
Value:
Value:
0
2
1
0
1
Value: 1
Value: 3
Value: 0
continued on next page
11
Class Vertex
Name
STAR_UNDIRECTED
STRONG
TRANSITIVITY_NAN
TRANSITIVITY_ZERO
TREE_IN
TREE_OUT
TREE_UNDIRECTED
WEAK
__package__
arpack_options
name
1.4
Package igraph
Description
Value: 2
Value: 2
Value: 0
Value: 1
Value: 1
Value: 0
Value: 2
Value: 1
Value: igraph
Value: <igraph.ARPACKOptions object at
0x7fc6738b8cd0>
Value: write_svg
Class Vertex
object
igraph.Vertex
Class representing a single vertex in a graph.
The vertex is referenced by its index, so if the underlying graph changes, the semantics of the vertex object
might change as well (if the vertex indices are altered in the original graph).
The attributes of the vertex can be accessed by using the vertex as a hash:
>>> v["color"] = "red"
>>> print v["color"]
red
1.4.1
#doctest: +SKIP
#doctest: +SKIP
Methods
__delitem__(x, y)
del x[y]
__eq__(x, y)
x==y
__ge__(x, y)
x>=y
__getitem__(x, y)
x[y]
12
Class Vertex
Package igraph
__gt__(x, y)
x>y
__hash__(x )
hash(x)
Overrides: object.__hash__
__le__(x, y)
x<=y
__len__(x )
len(x)
__lt__(x, y)
x<y
__ne__(x, y)
x!=y
__repr__(x )
repr(x)
Overrides: object.__repr__
__setitem__(x, i, y)
x[i]=y
attribute_names()
Returns the list of vertex attribute names
Return Value
list
attributes()
Returns a dict of attribute names and values for the vertex
Return Value
dict
13
Class Vertex
Package igraph
betweenness(...)
Proxy method to Graph.betweenness()
This method calls the betweenness method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.betweenness() for details.
closeness(...)
Proxy method to Graph.closeness()
This method calls the closeness method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.closeness() for details.
constraint(...)
Proxy method to Graph.constraint()
This method calls the constraint method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.constraint() for details.
degree(...)
Proxy method to Graph.degree()
This method calls the degree method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.degree() for details.
delete(...)
Proxy method to Graph.delete_vertices()
This method calls the delete_vertices method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.delete_vertices() for details.
diversity(...)
Proxy method to Graph.diversity()
This method calls the diversity method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.diversity() for details.
14
Class Vertex
Package igraph
eccentricity(...)
Proxy method to Graph.eccentricity()
This method calls the eccentricity method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.eccentricity() for details.
get_shortest_paths(...)
Proxy method to Graph.get_shortest_paths()
This method calls the get_shortest_paths method of the Graph class with this vertex as the
first argument, and returns the result.
See Also: Graph.get_shortest_paths() for details.
indegree(...)
Proxy method to Graph.indegree()
This method calls the indegree method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.indegree() for details.
is_minimal_separator(...)
Proxy method to Graph.is_minimal_separator()
This method calls the is_minimal_separator method of the Graph class with this vertex as
the first argument, and returns the result.
See Also: Graph.is_minimal_separator() for details.
is_separator(...)
Proxy method to Graph.is_separator()
This method calls the is_separator method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.is_separator() for details.
neighbors(...)
Proxy method to Graph.neighbors()
This method calls the neighbors method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.neighbors() for details.
15
Class Vertex
Package igraph
outdegree(...)
Proxy method to Graph.outdegree()
This method calls the outdegree method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.outdegree() for details.
pagerank(...)
Proxy method to Graph.pagerank()
This method calls the pagerank method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.pagerank() for details.
personalized_pagerank(...)
Proxy method to Graph.personalized_pagerank()
This method calls the personalized_pagerank method of the Graph class with this vertex as
the first argument, and returns the result.
See Also: Graph.personalized_pagerank() for details.
predecessors(...)
Proxy method to Graph.predecessors()
This method calls the predecessors method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.predecessors() for details.
shortest_paths(...)
Proxy method to Graph.shortest_paths()
This method calls the shortest_paths method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.shortest_paths() for details.
strength(...)
Proxy method to Graph.strength()
This method calls the strength method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.strength() for details.
16
Class Graph
Package igraph
successors(...)
Proxy method to Graph.successors()
This method calls the successors method of the Graph class with this vertex as the first
argument, and returns the result.
See Also: Graph.successors() for details.
update_attributes(E, **F )
Updates the attributes of the vertex from dict/iterable E and F.
If E has a keys() method, it does: for k in E: self[k] = E[k]. If E lacks a keys()
method, it does: for (k, v) in E: self[k] = v. In either case, this is followed by: for k
in F: self[k] = F[k].
This method thus behaves similarly to the update() method of Python dictionaries.
Return Value
None
Properties
Name
graph
index
Inherited from object
__class__
1.5
Description
The graph the vertex belongs to
Index of the vertex
Class Graph
object
igraph.GraphBase
igraph.Graph
Generic graph.
This class is built on top of GraphBase, so the order of the methods in the Epydoc documentation is a little bit obscure: inherited methods come after the ones implemented directly
in the subclass. Graph provides many functions that GraphBase does not, mostly because
17
Class Graph
Package igraph
these functions are not speed critical and they were easier to implement in Python than in
pure C. An example is the attribute handling in the constructor: the constructor of Graph
accepts three dictionaries corresponding to the graph, vertex and edge attributes while the
constructor of GraphBase does not. This extension was needed to make Graph serializable
through the pickle module. Graph also overrides some functions from GraphBase to provide a more convenient interface; e.g., layout functions return a Layout instance from Graph
instead of a list of coordinate pairs.
Graphs can also be indexed by strings or pairs of vertex indices or vertex names. When a
graph is indexed by a string, the operation translates to the retrieval, creation, modification
or deletion of a graph attribute:
>>>
>>>
>>>
g = Graph.Full(3)
g["name"] = "Triangle
g["name"]
graph"
Triangle graph
>>> del
g["name"]
When a graph is indexed by a pair of vertex indices or names, the graph itself is treated as
an adjacency matrix and the corresponding cell of the matrix is returned:
>>>
>>>
>>>
g = Graph.Full(3)
g.vs["name"] = ["A",
g[1, 2]
"B", "C"]
1
>>>
g["A",
"B"]
1
>>>
>>>
g["A", "B"] = 0
g.ecount()
Assigning values different from zero or one to the adjacency matrix will be translated to one,
unless the graph is weighted, in which case the numbers will be treated as weights:
>>>
g.is_weighted()
False
>>>
>>>
g["A",
g["A",
"B"]
= 2
"B"]
1
>>>
>>>
g.es["weight"] = 1.0
g.is_weighted()
True
>>>
>>>
g["A",
g["A",
"B"]
= 2
"B"]
2
>>>
g.es["weight"]
18
Class Graph
Package igraph
[1.0, 1.0, 2]
1.5.1
Methods
omega()
Returns the clique number of the graph.
The clique number of the graph is the size of the largest clique.
See Also: largest_cliques() for the largest cliques.
alpha()
Returns the independence number of the graph.
The independence number of the graph is the size of the largest independent
vertex set.
See Also: largest_independent_vertex_sets() for the largest independent
vertex sets
shell_index(mode=ALL)
Finds the coreness (shell index) of the vertices of the network.
The k -core of a graph is a maximal subgraph in which each vertex has at least
degree k. (Degree here means the degree in the subgraph of course). The
coreness of a vertex is k if it is a member of the k -core but not a member of
the k+1 -core.
Parameters
mode: whether to compute the in-corenesses (IN), the out-corenesses
(OUT) or the undirected corenesses (ALL). Ignored and
assumed to be ALL for undirected graphs.
Return Value
the corenesses for each vertex.
Reference: Vladimir Batagelj, Matjaz Zaversnik: An O(m) Algorithm for
Core Decomposition of Networks.
cut_vertices()
Returns the list of articulation points in the graph.
A vertex is an articulation point if its removal increases the number of
connected components in the graph.
19
Class Graph
Package igraph
scale:
weights:
Return Value
the eigenvector centralities in a list and optionally the largest
eigenvalue (as a second member of a tuple)
20
Class Graph
Package igraph
target:
checks:
21
Class Graph
Package igraph
22
Class Graph
Package igraph
target:
checks:
23
Class Graph
Package igraph
24
Class Graph
Package igraph
Return Value
the shortest path lengths for given vertices in a matrix
25
Class Graph
Package igraph
subgraph(vertices, implementation="auto")
Returns a subgraph spanned by the given vertices.
Parameters
vertices:
26
Class Graph
Package igraph
edges:
directed:
Overrides: object.__init__
add_edge(source, target, **kwds)
Adds a single edge to the graph.
Keyword arguments (except the source and target arguments) will be assigned
to the edge as attributes.
Parameters
source: the source vertex of the edge or its name.
target: the target vertex of the edge or its name.
add_edges(es)
Adds some edges to the graph.
Parameters
es: the list of edges to be added. Every edge is represented with a
tuple containing the vertex IDs or names of the two endpoints.
Vertices are enumerated from zero.
Overrides: igraph.GraphBase.add_edges
27
Class Graph
Package igraph
add_vertex(name=None, **kwds)
Adds a single vertex to the graph. Keyword arguments will be assigned as
vertex attributes. Note that name as a keyword argument is treated specially;
if a graph has name as a vertex attribute, it allows one to refer to vertices by
their names in most places where igraph expects a vertex ID.
add_vertices(n)
Adds some vertices to the graph.
Parameters
n: the number of vertices to be added, or the name of a single vertex
to be added, or an iterable of strings, each corresponding to the
name of a vertex to be added. Names will be assigned to the
name vertex attribute.
Overrides: igraph.GraphBase.add_vertices
adjacent(vertex, mode=OUT)
Returns the edges a given vertex is incident on.
Deprecated: replaced by Graph.incident() since igraph 0.6
as_directed(*args, **kwds)
Returns a directed copy of this graph. Arguments are passed on to
Graph.to_directed() that is invoked on the copy.
as_undirected(*args, **kwds)
Returns an undirected copy of this graph. Arguments are passed on to
Graph.to_undirected() that is invoked on the copy.
28
Class Graph
Package igraph
Parameters
es: the list of edges to be removed. Edges are identifed by edge IDs.
EdgeSeq objects are also accepted here.
Overrides: igraph.GraphBase.delete_edges
indegree(self, *args, **kwds)
Returns the in-degrees in a list.
See degree for possible arguments.
outdegree(self, *args, **kwds)
Returns the out-degrees in a list.
See degree for possible arguments.
29
Class Graph
Package igraph
target:
30
Class Graph
Package igraph
biconnected_components(self, return_articulation_points=False)
Calculates the biconnected components of the graph.
Parameters
return_articulation_points: whether to return the articulation
points as well
Return Value
a VertexCover object describing the biconnected components, and
optionally the list of articulation points as well
Overrides: igraph.GraphBase.biconnected_components
blocks(self, return_articulation_points=False)
Calculates the biconnected components of the graph.
Parameters
return_articulation_points: whether to return the articulation
points as well
Return Value
a VertexCover object describing the biconnected components, and
optionally the list of articulation points as well
cohesive_blocks()
Calculates the cohesive block structure of the graph.
Cohesive blocking is a method of determining hierarchical subsets of graph
vertices based on their structural cohesion (i.e. vertex connectivity). For a
given graph G, a subset of its vertices S is said to be maximally k-cohesive if
there is no superset of S with vertex connectivity greater than or equal to k.
Cohesive blocking is a process through which, given a k-cohesive set of
vertices, maximally l-cohesive subsets are recursively identified with l > k.
Thus a hierarchy of vertex subsets is obtained in the end, with the entire
graph G at its root.
Return Value
an instance of CohesiveBlocks. See the documentation of
CohesiveBlocks for more information.
Overrides: igraph.GraphBase.cohesive_blocks
See Also: CohesiveBlocks
31
Class Graph
Package igraph
clusters(mode=STRONG)
Calculates the (strong or weak) clusters (connected components) for a given
graph.
Parameters
mode: must be either STRONG or WEAK, depending on the clusters
being sought. Optional, defaults to STRONG.
Return Value
a VertexClustering object
Overrides: igraph.GraphBase.clusters
components(mode=STRONG)
Calculates the (strong or weak) clusters (connected components) for a given
graph.
Parameters
mode: must be either STRONG or WEAK, depending on the clusters
being sought. Optional, defaults to STRONG.
Return Value
a VertexClustering object
degree_distribution(bin_width=1, ...)
Calculates the degree distribution of the graph.
Unknown keyword arguments are directly passed to degree().
Parameters
bin_width: the bin width of the histogram
Return Value
a histogram representing the degree distribution of the graph.
32
Class Graph
Package igraph
dyad_census()
Calculates the dyad census of the graph.
Dyad census means classifying each pair of vertices of a directed graph into
three categories: mutual (there is an edge from a to b and also from b to a),
asymmetric (there is an edge from a to b or from b to a but not the other way
round) and null (there is no connection between a and b).
Return Value
a DyadCensus object.
Overrides: igraph.GraphBase.dyad_census
Reference: Holland, P.W. and Leinhardt, S. (1970). A Method for Detecting
Structure in Sociometric Data. American Journal of Sociology, 70, 492-513.
get_adjacency(self, type=2, attribute=None, default=0, eids=False)
Returns the adjacency matrix of a graph.
Parameters
type:
eids:
Return Value
the adjacency matrix as a Matrix.
Overrides: igraph.GraphBase.get_adjacency
33
Class Graph
Package igraph
get_adjlist(mode=OUT)
Returns the adjacency list representation of the graph.
The adjacency list representation is a list of lists. Each item of the outer list
belongs to a single vertex of the graph. The inner list contains the neighbors
of the given vertex.
Parameters
mode: if OUT, returns the successors of the vertex. If IN, returns the
predecessors of the vertex. If ALL, both the predecessors and
the successors will be returned. Ignored for undirected graphs.
get_adjedgelist(mode=OUT)
Returns the incidence list representation of the graph.
Deprecated: replaced by Graph.get_inclist() since igraph 0.6
See Also: Graph.get_inclist()
get_inclist(mode=OUT)
Returns the incidence list representation of the graph.
The incidence list representation is a list of lists. Each item of the outer list
belongs to a single vertex of the graph. The inner list contains the IDs of the
incident edges of the given vertex.
Parameters
mode: if OUT, returns the successors of the vertex. If IN, returns the
predecessors of the vertex. If ALL, both the predecessors and
the successors will be returned. Ignored for undirected graphs.
34
Class Graph
Package igraph
Return Value
the Gomory-Hu tree as a Graph object.
Overrides: igraph.GraphBase.gomory_hu_tree
is_named()
Returns whether the graph is named, i.e. whether it has a "name" vertex
attribute.
is_weighted()
Returns whether the graph is weighted, i.e. whether it has a "weight" edge
attribute.
35
Class Graph
Package igraph
36
Class Graph
Package igraph
target:
target:
37
Class Graph
Package igraph
modularity(membership, weights=None)
Calculates the modularity score of the graph with respect to a given clustering.
The modularity of a graph w.r.t. some division measures how good the
division is, or how separated are the different vertex types from each other.
Its defined as Q=1/(2m)*sum(Aij-ki*kj/(2m)delta(ci,cj),i,j). m is the number
of edges, Aij is the element of the A adjacency matrix in row i and column j,
ki is the degree of node i, kj is the degree of node j, and Ci and cj are the
types of the two vertices (i and j ). delta(x,y) is one iff x=y, 0 otherwise.
If edge weights are given, the definition of modularity is modified as follows:
Aij becomes the weight of the corresponding edge, ki is the total weight of
edges adjacent to vertex i, kj is the total weight of edges adjacent to vertex j
and m is the total edge weight in the graph.
Parameters
membership: a membership list or a VertexClustering object
weights:
Return Value
the modularity score
Overrides: igraph.GraphBase.modularity
Reference: MEJ Newman and M Girvan: Finding and evaluating community
structure in networks. Phys Rev E 69 026113, 2004.
path_length_hist(directed =True)
Returns the path length histogram of the graph
Parameters
directed: whether to consider directed paths. Ignored for
undirected graphs.
Return Value
a Histogram object. The object will also have an unconnected
attribute that stores the number of unconnected vertex pairs (where
the second vertex can not be reached from the first one). The latter
one will be of type long (and not a simple integer), since this can be
very large.
Overrides: igraph.GraphBase.path_length_hist
38
Class Graph
Package igraph
directed:
damping:
weights:
eps:
Return Value
a list with the Google PageRank values of the specified vertices.
39
Class Graph
Package igraph
40
Class Graph
Package igraph
Class Graph
Package igraph
42
Class Graph
Package igraph
Return Value
an appropriate VertexClustering object with an extra attribute
called codelength that stores the code length determined by the
algorithm.
Overrides: igraph.GraphBase.community_infomap
Reference:
M. Rosvall and C. T. Bergstrom: Maps of information flow
reveal community structure in complex networks, PNAS 105,
1118 (2008). http://dx.doi.org/10.1073/pnas.0706851105 ,
http://arxiv.org/abs/0707.0609 .
M. Rosvall, D. Axelsson, and C. T. Bergstrom: The map
equation, Eur. Phys. J. Special Topics 178, 13 (2009).
http://dx.doi.org/10.1140/epjst/e2010-01179-1 ,
http://arxiv.org/abs/0906.1405 .
43
Class Graph
Package igraph
community_leading_eigenvector_naive(clusters=None,
return_merges=False)
A naive implementation of Newmans eigenvector community structure
detection. This function splits the network into two components according to
the leading eigenvector of the modularity matrix and then recursively takes
the given number of steps by splitting the communities as individual networks.
This is not the correct way, however, see the reference for explanation.
Consider using the correct community_leading_eigenvector method instead.
Parameters
clusters:
44
Class Graph
Package igraph
community_leading_eigenvector(clusters=None, weights=None,
arpack_options=None)
Newmans leading eigenvector method for detecting community structure.
This is the proper implementation of the recursive, divisive algorithm: each
split is done by maximizing the modularity regarding the original network.
Parameters
clusters:
weights:
45
Class Graph
Package igraph
Return Value
an appropriate VertexClustering object.
Overrides: igraph.GraphBase.community_label_propagation
Reference: Raghavan, U.N. and Albert, R. and Kumara, S. Near linear time
algorithm to detect community structures in large-scale networks. Phys Rev E
76:036106, 2007. http://arxiv.org/abs/0709.2938 .
46
Class Graph
Package igraph
47
Class Graph
Package igraph
48
Class Graph
Package igraph
49
Class Graph
Package igraph
spins:
parupdate:
start_temp:
stop_temp:
cool_fact:
update_rule:
gamma:
Class Graph
Package igraph
Return Value
a VertexDendrogram object, initially cut at the maximum
modularity.
Overrides: igraph.GraphBase.community_walktrap
Reference: Pascal Pons, Matthieu Latapy: Computing communities in large
networks using random walks, http://arxiv.org/abs/physics/0512106 .
k_core(self, *args)
Returns some k-cores of the graph.
The method accepts an arbitrary number of arguments representing the
desired indices of the k -cores to be returned. The arguments can also be lists
or tuples. The result is a single Graph object if an only integer argument was
given, otherwise the result is a list of Graph objects representing the desired
k-cores in the order the arguments were specified. If no argument is given,
returns all k -cores in increasing order of k.
51
Class Graph
Package igraph
Parameters
52 be one of the registered layout
layout: the layout to use. This can
names or a callable which returns either a Layout object or
a list of lists containing the coordinates. If None, uses the
value of the plotting.layout configuration key.
Class Graph
Package igraph
53
Class Graph
Package igraph
weights:
hgap:
vgap:
maxiter:
Class Graph
Package igraph
Return Value
an instance of Matching.
write_adjacency(self, f, sep= , eol =\n, *args, **kwds)
Writes the adjacency matrix of the graph to the given file
All the remaining arguments not mentioned here are passed intact to
Graph.get_adjacency.
Parameters
f: the name of the file to be written.
sep: the string that separates the matrix elements in a row
eol: the string that separates the rows of the matrix. Please note
that igraph is able to read back the written adjacency matrix if
and only if this is a single newline character
55
Class Graph
Package igraph
sep:
Return Value
the created graph
write_dimacs(self, f, source=None, target=None, capacity=capacity)
Writes the graph in DIMACS format to the given file.
Parameters
f:
source:
target:
56
Class Graph
Package igraph
57
Class Graph
Package igraph
58
Class Graph
Package igraph
Read_Pickle(klass, fname=None)
Reads a graph from Python pickled format
Parameters
fname: the name of the file, a stream to read from, or a string
containing the pickled data. The string is assumed to hold
pickled data if it is longer than 40 characters and contains a
substring thats peculiar to pickled versions of an igraph
Graph object.
Return Value
the created graph object.
Read_Picklez(klass, fname, *args, **kwds)
Reads a graph from compressed Python pickled format, uncompressing it
on-the-fly.
Parameters
fname: the name of the file or a stream to read from.
Return Value
the created graph object.
59
Class Graph
Package igraph
layout:
width:
height:
labels:
colors:
shapes:
60
Class Graph
Package igraph
61
Class Graph
Package igraph
62
Class Graph
Package igraph
Raises
IOError if the file format cant be identified and none was given.
63
Class Graph
Package igraph
Raises
IOError if the file format cant be identified and none was given.
64
Class Graph
Package igraph
edges:
directed:
Return Value
the graph that was constructed
65
Class Graph
Package igraph
directed:
weights:
Return Value
Class Graph
Package igraph
>>> from
>>>
# empty graph
g = Graph.Formula("A-B")
g.vs["name"]
# undirected graph
[A, B]
>>> print
g.get_edgelist()
[(0, 1)]
>>>
>>>
g2 = Graph.Formula("A-----------B")
g2.isomorphic(g)
True
>>>
>>>
g = Graph.Formula("A
g.vs["name"]
--->
[A, B]
>>> print
67
A->B
If you have may disconnected componnets, you can separate them with
commas. You can also specify isolated vertices:
Class Graph
Package igraph
True
>>>
g.vs["type"]
Parameters
types:
edges:
68
Class Graph
Package igraph
g = Graph.Full_Bipartite(2, 3)
g.is_bipartite()
True
>>>
g.vs["type"]
Parameters
n1:
n2:
Return Value
the graph with a binary vertex attribute named "type" that stores
the vertex classes.
69
Class Graph
Package igraph
n2:
p:
m:
70
Class Graph
Package igraph
Parameters
matrix:
71
Class Graph
Package igraph
g = Graph.Full_Bipartite(10, 5)
g1, g2 = g.bipartite_projection()
g1.isomorphic(Graph.Full(10))
True
>>>
g2.isomorphic(Graph.Full(5))
True
Parameters
types:
which:
Return Value
a tuple containing the two projected one-mode graphs if which is not
1 or 2, or the projected one-mode graph specified by the which
argument if its value is 0, 1, False or True.
72
Overrides: igraph.GraphBase.bipartite_projection
Class Graph
Package igraph
bipartite_projection_size(types="type")
Calculates the number of vertices and edges in the bipartite projections of this
graph according to the specified vertex types. This is useful if you have a
bipartite graph and you want to estimate the amount of memory you would
need to calculate the projections themselves.
Parameters
types: an igraph vector containing the vertex types, or an attribute
name. Anything that evalulates to False corresponds to
vertices of the first kind, everything else to the second kind.
Return Value
a 4-tuple containing the number of vertices and edges in the first
projection, followed by the number of vertices and edges in the
second projection.
Overrides: igraph.GraphBase.bipartite_projection_size
get_incidence(self, types="type")
Returns the incidence matrix of a bipartite graph. The incidence matrix is an
n times m matrix, where n and m are the number of vertices in the two vertex
classes.
Parameters
types: an igraph vector containing the vertex types, or an attribute
name. Anything that evalulates to False corresponds to
vertices of the first kind, everything else to the second kind.
Return Value
the incidence matrix and two lists in a triplet. The first list defines
the mapping between row indices of the matrix and the original
vertex IDs. The second list is the same for the column indices.
Overrides: igraph.GraphBase.get_incidence
__iadd__(self, other )
In-place addition (disjoint union).
See Also: __add__
73
Class Graph
Package igraph
__add__(self, other )
Copies the graph and extends the copy depending on the type of the other
object given.
Parameters
other: if it is an integer, the copy is extended by the given number
of vertices. If it is a string, the copy is extended by a single
vertex whose name attribute will be equal to the given string.
If it is a tuple with two elements, the copy is extended by a
single edge. If it is a list of tuples, the copy is extended by
multiple edges. If it is a Graph, a disjoint union is performed.
__isub__(self, other )
In-place subtraction (difference).
See Also: __sub__
__sub__(self, other )
Removes the given object(s) from the graph
Parameters
other: if it is an integer, removes the vertex with the given ID from
the graph (note that the remaining vertices will get
re-indexed!). If it is a tuple, removes the given edge. If it is
a graph, takes the difference of the two graphs. Accepts lists
of integers or lists of tuples as well, but they cant be mixed!
Also accepts Edge and EdgeSeq objects.
__mul__(self, other )
Copies exact replicas of the original graph an arbitrary number of times.
Parameters
other: if it is an integer, multiplies the graph by creating the given
number of identical copies and taking the disjoint union of
them.
__nonzero__(self )
Returns True if the graph has at least one vertex, False otherwise.
74
Class Graph
Package igraph
__coerce__(self, other )
Coercion rules.
This method is needed to allow the graph to react to additions with lists,
tuples, integers, strings, vertices, edges and so on.
__reduce__(self )
Support for pickling.
Overrides: object.__reduce__
75
Class Graph
Package igraph
Class Graph
Package igraph
__str__(self )
Returns a string representation of the graph.
Behind the scenes, this method constructs a GraphSummary instance and
invokes its __str__ method with a verbosity of 1 and attribute printing
turned off.
See the documentation of GraphSummary for more details about the output.
Overrides: object.__str__
summary(self, verbosity=0, width=None, *args, **kwds)
Returns the summary of the graph.
The output of this method is similar to the output of the __str__ method. If
verbosity is zero, only the header line is returned (see __str__ for more
details), otherwise the header line and the edge list is printed.
Behind the scenes, this method constructs a GraphSummary object and invokes
its __str__ method.
Parameters
verbosity: if zero, only the header line is returned (see __str__ for
more details), otherwise the header line and the full
edge list is printed.
width:
Return Value
the summary of the graph.
layout_fruchterman_reingold_3d(*args, **kwds)
Alias for layout_fruchterman_reingold() with dim=3.
See Also: Graph.layout_fruchterman_reingold()
layout_kamada_kawai_3d(*args, **kwds)
Alias for layout_kamada_kawai() with dim=3.
See Also: Graph.layout_kamada_kawai()
layout_random_3d(*args, **kwds)
Alias for layout_random() with dim=3.
See Also: Graph.layout_random()
77
Class Graph
Package igraph
layout_grid_3d(*args, **kwds)
Alias for layout_grid() with dim=3.
See Also: Graph.layout_grid()
layout_sphere(*args, **kwds)
Alias for layout_circle() with dim=3.
See Also: Graph.layout_circle()
layout_bipartite(types="type", hgap=1, vgap=1, maxiter =100)
Place the vertices of a bipartite graph in two layers.
The layout is created by placing the vertices in two rows, according to their
types. The positions of the vertices within the rows are then optimized to
minimize the number of edge crossings using the heuristic used by the
Sugiyama layout algorithm.
Parameters
types:
hgap:
vgap:
78
Class Graph
Package igraph
layout_circle(dim=2)
Places the vertices of the graph uniformly on a circle or a sphere.
Parameters
dim: the desired number of dimensions for the layout. dim=2 means
a 2D layout, dim=3 means a 3D layout.
Return Value
the calculated layout.
Overrides: igraph.GraphBase.layout_circle
79
Class Graph
Package igraph
fixed:
options: if you give a string argument here, you can select from five
default preset parameterisations: default, coarsen for a
coarser layout, coarsest for an even coarser layout,
refine for refining an existing layout and final for
finalizing a layout. If you supply an object that is not a
string, the DrL layout parameters are retrieved from the
respective keys of the object (so it should be a dict or
something else that supports the mapping protocol). The
following keys can be used:
edge_cut: edge cutting is done in the late stages of
the algorithm in order to achieve less dense layouts.
Edges are cut if there is a lot of stress on them (a large
value in the objective function sum). The edge cutting
parameter is a value between 0 and 1 with 0
representing no edge cutting and 1 representing
maximal edge cutting.
init_iterations: number of iterations in the
initialization phase
init_temperature: start temperature during
initialization
init_attraction: attraction during initialization
init_damping_mult: damping multiplier during
initialization
80
liquid_iterations, liquid_temperature,
liquid_attraction, liquid_damping_mult: same
parameters for the liquid phase
expansion_iterations, expansion_temperature,
Class Graph
Package igraph
maxiter:
maxdelta:
area:
coolexp:
maxx:
miny:
maxy:
minz:
maxz:
seed:
dim:
Return Value
the calculated layout.
Overrides: igraph.GraphBase.layout_fruchterman_reingold
Class Graph
Package igraph
node_charge:
node_mass:
spring_length:
Return Value
the calculated layout.
Overrides: igraph.GraphBase.layout_graphopt
82
Class Graph
Package igraph
Return Value
the calculated layout.
Overrides: igraph.GraphBase.layout_grid
83
Class Graph
Package igraph
maxdelta:
area:
coolexp:
seed:
Return Value
the calculated layout.
Overrides: igraph.GraphBase.layout_grid_fruchterman_reingold
84
Class Graph
Package igraph
maxx:
miny:
maxy:
minz:
maxz:
seed:
dim:
Return Value
the calculated layout.
Overrides: igraph.GraphBase.layout_kamada_kawai
85
Class Graph
Package igraph
maxdelta:
area:
coolexp:
root:
Return Value
the calculated layout.
Overrides: igraph.GraphBase.layout_lgl
86
Class Graph
Package igraph
dim:
87
Class Graph
Package igraph
layout_random(dim=2)
Places the vertices of the graph randomly.
Parameters
dim: the desired number of dimensions for the layout. dim=2 means
a 2D layout, dim=3 means a 3D layout.
Return Value
the coordinate pairs in a list.
Overrides: igraph.GraphBase.layout_random
layout_reingold_tilford(mode="out", root=None, rootlevel =None)
Places the vertices on a 2D plane according to the Reingold-Tilford layout
algorithm.
This is a tree layout. If the given graph is not a tree, a breadth-first search is
executed first to obtain a possible spanning tree.
Parameters
mode:
root:
88
Class Graph
Package igraph
layout_reingold_tilford_circular(mode="out", root=None,
rootlevel =None)
Circular Reingold-Tilford layout for trees.
This layout is similar to the Reingold-Tilford layout, but the vertices are
placed in a circular way, with the root vertex in the center.
See layout_reingold_tilford for the explanation of the parameters.
Return Value
the calculated layout.
Overrides: igraph.GraphBase.layout_reingold_tilford_circular
See Also: layout_reingold_tilford
Reference: EM Reingold, JS Tilford: Tidier Drawings of Trees. IEEE
Transactions on Software Engineering 7:22, 223-228, 1981.
layout_star(center =0, order =None)
Calculates a star-like layout for the graph.
Parameters
center: the ID of the vertex to put in the center
order: a numeric vector giving the order of the vertices (including
the center vertex!). If it is None, the vertices will be placed
in increasing vertex ID order.
Return Value
the calculated layout.
Overrides: igraph.GraphBase.layout_star
Inherited from igraph.GraphBase(Section 1.11)
Adjacency(), Asymmetric_Preference(), Atlas(), Barabasi(), De_Bruijn(), Degree_Sequence(), Erdos_Renyi(), Establishment(), Famous(), Forest_Fire(), Full(),
Full_Citation(), Growing_Random(), Isoclass(), K_Regular(), Kautz(), LCF(),
Lattice(), Preference(), Read_DL(), Read_Edgelist(), Read_GML(), Read_GraphDB(),
Read_GraphML(), Read_Lgl(), Read_Ncol(), Read_Pajek(), Recent_Degree(),
Ring(), SBM(), Star(), Static_Fitness(), Static_Power_Law(), Tree(), Watts_Strogatz(),
Weighted_Adjacency(), __and__(), __delitem__(), __getitem__(), __invert__(), __new__(), __or__(), __rand__(), __ror__(), __setitem__(),
all_minimal_st_separators(), are_connected(), articulation_points(), assortativity(), assortativity_degree(), assortativity_nominal(), attributes(), authority_score(),
average_path_length(), betweenness(), bfs(), bfsiter(), bibcoupling(), canonical_permutation(),
clique_number(), cliques(), closeness(), cocitation(), complementer(), compose(),
constraint(), contract_vertices(), convergence_degree(), convergence_field_size(),
89
Class Graph
Package igraph
Properties
Name
vs
es
Inherited from object
__class__
Description
The vertex sequence of the graph
The edge sequence of the graph
90
Class VertexSeq
1.6
Package igraph
Class VertexSeq
object
igraph.drawing.graph.VertexSeq
igraph.VertexSeq
Class representing a sequence of vertices in the graph.
This class is most easily accessed by the vs field of the Graph object, which returns an
ordered sequence of all vertices in the graph. The vertex sequence can be refined by invoking
the VertexSeq.select() method. VertexSeq.select() can also be accessed by simply
calling the VertexSeq object.
An alternative way to create a vertex sequence referring to a given graph is to use the
constructor directly:
>>>
>>>
>>>
g = Graph.Full(3)
vs = VertexSeq(g)
restricted_vs = VertexSeq(g, [0, 1])
The individual vertices can be accessed by indexing the vertex sequence object. It can be
used as an iterable as well, or even in a list comprehension:
>>>
>>>
...
g=Graph.Full(3)
for v in g.vs:
v["value"] = v.index ** 2
...
>>>
[v["value"] ** 0.5
for
in
g.vs]
The vertex set can also be used as a dictionary where the keys are the attribute names.
The values corresponding to the keys are the values of the given attribute for every vertex
selected by the sequence.
>>>
g=Graph.Full(3)
idx, v in enumerate(g.vs):
v["weight"] = idx*(idx+1)
>>> for
...
...
>>>
g.vs["weight"]
[0, 2, 6]
>>>
>>>
If you specify a sequence that is shorter than the number of vertices in the VertexSeq, the
91
Class VertexSeq
Package igraph
sequence is reused:
>>>
>>>
>>>
g = Graph.Tree(7, 2)
g.vs["color"] = ["red",
g.vs["color"]
"green"]
You can even pass a single string or integer, it will be considered as a sequence of length 1:
>>>
>>>
g.vs["color"] =
g.vs["color"]
"red"
Some methods of the vertex sequences are simply proxy methods to the corresponding methods in the Graph object. One such example is VertexSeq.degree():
>>>
>>>
g=Graph.Tree(7, 2)
g.vs.degree()
[2, 3, 3, 1, 1, 1, 1]
>>>
g.vs.degree() == g.degree()
True
1.6.1
Methods
attributes(self )
Returns the list of all the vertex attributes in the graph associated to this
vertex sequence.
find(self, *args, **kwds)
Returns the first vertex of the vertex sequence that matches some criteria.
The selection criteria are equal to the ones allowed by VertexSeq.select. See
VertexSeq.select for more details.
For instance, to find the first vertex with name foo in graph g:
>>>
g.vs.find(name="foo")
#doctest:+SKIP
g.vs.find(_degree=0)
#doctest:+SKIP
Return Value
Vertex
Overrides: igraph.drawing.graph.VertexSeq.find
92
Class VertexSeq
Package igraph
eq: equal to
ne: not equal to
lt: less than
gt: greater than
le: less than or equal to
ge: greater than or equal to
in: checks if the value of an attribute is in a given list
notin: checks if the value of an attribute is not in a given list
For instance, if you want to filter vertices with a numeric age property larger
than 200, you have to write:
>>>
g.vs.select(age_gt=200)
#doctest: +SKIP
#doctest: +SKIP
If the operator is omitted, it defaults to eq. For instance, the following selector
selects vertices whose cluster property equals to 2:
Class VertexSeq
Package igraph
94
Class VertexSeq
Package igraph
degree(*args, **kwds)
Proxy method to Graph.degree()
This method calls the degree() method of the Graph class restricted to this
sequence, and returns the result.
See Also: Graph.degree() for details.
delete(*args, **kwds)
Proxy method to Graph.delete_vertices()
This method calls the delete_vertices() method of the Graph class
restricted to this sequence, and returns the result.
See Also: Graph.delete_vertices() for details.
diversity(*args, **kwds)
Proxy method to Graph.diversity()
This method calls the diversity() method of the Graph class restricted to
this sequence, and returns the result.
See Also: Graph.diversity() for details.
eccentricity(*args, **kwds)
Proxy method to Graph.eccentricity()
This method calls the eccentricity() method of the Graph class restricted to
this sequence, and returns the result.
See Also: Graph.eccentricity() for details.
get_shortest_paths(*args, **kwds)
Proxy method to Graph.get_shortest_paths()
This method calls the get_shortest_paths() method of the Graph class
restricted to this sequence, and returns the result.
See Also: Graph.get_shortest_paths() for details.
95
Class VertexSeq
Package igraph
indegree(*args, **kwds)
Proxy method to Graph.indegree()
This method calls the indegree() method of the Graph class restricted to this
sequence, and returns the result.
See Also: Graph.indegree() for details.
is_minimal_separator(*args, **kwds)
Proxy method to Graph.is_minimal_separator()
This method calls the is_minimal_separator() method of the Graph class
restricted to this sequence, and returns the result.
See Also: Graph.is_minimal_separator() for details.
is_separator(*args, **kwds)
Proxy method to Graph.is_separator()
This method calls the is_separator() method of the Graph class restricted to
this sequence, and returns the result.
See Also: Graph.is_separator() for details.
isoclass(*args, **kwds)
Proxy method to Graph.isoclass()
This method calls the isoclass() method of the Graph class restricted to this
sequence, and returns the result.
See Also: Graph.isoclass() for details.
maxdegree(*args, **kwds)
Proxy method to Graph.maxdegree()
This method calls the maxdegree() method of the Graph class restricted to
this sequence, and returns the result.
See Also: Graph.maxdegree() for details.
96
Class VertexSeq
Package igraph
outdegree(*args, **kwds)
Proxy method to Graph.outdegree()
This method calls the outdegree() method of the Graph class restricted to
this sequence, and returns the result.
See Also: Graph.outdegree() for details.
pagerank(*args, **kwds)
Proxy method to Graph.pagerank()
This method calls the pagerank() method of the Graph class restricted to this
sequence, and returns the result.
See Also: Graph.pagerank() for details.
personalized_pagerank(*args, **kwds)
Proxy method to Graph.personalized_pagerank()
This method calls the personalized_pagerank() method of the Graph class
restricted to this sequence, and returns the result.
See Also: Graph.personalized_pagerank() for details.
shortest_paths(*args, **kwds)
Proxy method to Graph.shortest_paths()
This method calls the shortest_paths() method of the Graph class restricted
to this sequence, and returns the result.
See Also: Graph.shortest_paths() for details.
similarity_dice(*args, **kwds)
Proxy method to Graph.similarity_dice()
This method calls the similarity_dice() method of the Graph class
restricted to this sequence, and returns the result.
See Also: Graph.similarity_dice() for details.
97
Class EdgeSeq
Package igraph
similarity_jaccard(*args, **kwds)
Proxy method to Graph.similarity_jaccard()
This method calls the similarity_jaccard() method of the Graph class
restricted to this sequence, and returns the result.
See Also: Graph.similarity_jaccard() for details.
subgraph(*args, **kwds)
Proxy method to Graph.subgraph()
This method calls the subgraph() method of the Graph class restricted to this
sequence, and returns the result.
See Also: Graph.subgraph() for details.
Inherited from igraph.drawing.graph.VertexSeq
__delitem__(), __getitem__(), __init__(), __len__(), __new__(), __setitem__(),
attribute_names(), get_attribute_values(), set_attribute_values()
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __reduce__(),
__reduce_ex__(), __repr__(), __setattr__(), __sizeof__(), __str__(),
__subclasshook__()
1.6.2
Properties
Name
Description
Inherited from igraph.drawing.graph.VertexSeq
graph, indices
Inherited from object
__class__
1.7
Class EdgeSeq
object
igraph._igraph.EdgeSeq
igraph.EdgeSeq
Class representing a sequence of edges in the graph.
98
Class EdgeSeq
Package igraph
This class is most easily accessed by the es field of the Graph object, which returns an
ordered sequence of all edges in the graph. The edge sequence can be refined by invoking
the EdgeSeq.select() method. EdgeSeq.select() can also be accessed by simply calling
the EdgeSeq object.
An alternative way to create an edge sequence referring to a given graph is to use the
constructor directly:
>>>
>>>
>>>
g = Graph.Full(3)
es = EdgeSeq(g)
restricted_es = EdgeSeq(g, [0, 1])
The individual edges can be accessed by indexing the edge sequence object. It can be used
as an iterable as well, or even in a list comprehension:
>>>
g=Graph.Full(3)
e in g.es:
print e.tuple
>>> for
...
...
(0, 1)
(0, 2)
(1, 2)
>>>
[max(e.tuple)
for
in
g.es]
[1, 2, 2]
The edge sequence can also be used as a dictionary where the keys are the attribute names.
The values corresponding to the keys are the values of the given attribute of every edge in
the graph:
>>>
>>>
...
g=Graph.Full(3)
for idx, e in enumerate(g.es):
e["weight"] = idx*(idx+1)
...
>>>
g.es["weight"]
[0, 2, 6]
>>>
>>>
g.es["weight"] = range(3)
g.es["weight"]
[0, 1, 2]
If you specify a sequence that is shorter than the number of edges in the EdgeSeq, the
sequence is reused:
>>>
>>>
>>>
g = Graph.Tree(7, 2)
g.es["color"] = ["red",
g.es["color"]
"green"]
You can even pass a single string or integer, it will be considered as a sequence of length 1:
99
Class EdgeSeq
>>>
>>>
g.es["color"] =
g.es["color"]
Package igraph
"red"
Some methods of the edge sequences are simply proxy methods to the corresponding methods
in the Graph object. One such example is EdgeSeq.is_multiple():
>>>
>>>
g.es.is_multiple() == g.is_multiple()
True
1.7.1
Methods
attributes(self )
Returns the list of all the edge attributes in the graph associated to this edge
sequence.
find(self, *args, **kwds)
Returns the first edge of the edge sequence that matches some criteria.
The selection criteria are equal to the ones allowed by VertexSeq.select. See
VertexSeq.select for more details.
For instance, to find the first edge with weight larger than 5 in graph g:
>>>
g.es.find(weight_gt=5)
#doctest:+SKIP
Return Value
Edge
Overrides: igraph._igraph.EdgeSeq.find
100
Class EdgeSeq
Package igraph
eq: equal to
ne: not equal to
lt: less than
gt: greater than
le: less than or equal to
ge: greater than or equal to
in: checks if the value of an attribute is in a given list
notin: checks if the value of an attribute is not in a given list
For instance, if you want to filter edges with a numeric weight property larger
than 50, you have to write:
>>>
g.es.select(weight_gt=50)
#doctest: +SKIP
+SKIP
If the operator is omitted, it defaults to eq. For instance, the following selector
selects edges whose type property is intracluster:
Class EdgeSeq
Package igraph
102
Class ARPACKOptions
Package igraph
is_mutual(*args, **kwds)
Proxy method to Graph.is_mutual()
This method calls the is_mutual() method of the Graph class restricted to
this sequence, and returns the result.
See Also: Graph.is_mutual() for details.
subgraph(*args, **kwds)
Proxy method to Graph.subgraph_edges()
This method calls the subgraph_edges() method of the Graph class restricted
to this sequence, and returns the result.
See Also: Graph.subgraph_edges() for details.
Inherited from igraph._igraph.EdgeSeq
__delitem__(), __getitem__(), __init__(), __len__(), __new__(), __setitem__(),
attribute_names(), get_attribute_values(), is_all(), set_attribute_values()
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __reduce__(),
__reduce_ex__(), __repr__(), __setattr__(), __sizeof__(), __str__(),
__subclasshook__()
1.7.2
Properties
Name
Inherited from igraph._igraph.EdgeSeq
graph, indices
Inherited from object
__class__
1.8
Description
Class ARPACKOptions
object
igraph.ARPACKOptions
Class representing the parameters of the ARPACK module.
ARPACK is a Fortran implementation of the implicitly restarted Arnoldi method, an algo-
103
Class ARPACKOptions
Package igraph
rithm for calculating some of the eigenvalues and eigenvectors of a given matrix. igraph uses
this package occasionally, and this class can be used to fine-tune the behaviour of ARPACK
in such cases.
The class has several attributes which are not documented here, since they are usually of
marginal use to the ordinary user. See the source code of the original ARPACK Fortran
package (especially the file dsaupd.f) for a detailed explanation of the parameters. Only
the most basic attributes are explained here. Most of them are read only unless stated
otherwise.
bmat: type of the eigenproblem solved. I means standard eigenproblem (A*x =
lambda*x), G means generalized eigenproblem (A*x = lambda*B*x).
n: dimension of the eigenproblem
tol: precision. If less than or equal to zero, the standard machine precision is used as
computed by the LAPACK utility called dlamch. This can be modified.
mxiter: maximum number of update iterations to take. This can be modified. You can
also use maxiter.
iter: actual number of update iterations taken
numop: total number of OP*x operations
numopb: total number of B*x operations if bmat is G
numreo: total number of steps of re-orthogonalization
1.8.1
Methods
__new__(T, S, ...)
Return Value
a new object with type S, a subtype of T
Overrides: object.__new__
__str__(x )
str(x)
Overrides: object.__str__
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __init__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__subclasshook__()
1.8.2
Properties
104
Class Edge
Package igraph
Name
Inherited from object
__class__
1.9
Description
Class BFSIter
object
igraph.BFSIter
igraph BFS iterator object
1.9.1
Methods
__iter__(x )
iter(x)
next(x )
Return Value
the next value, or raise StopIteration
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __init__(),
__new__(), __reduce__(), __reduce_ex__(), __repr__(), __setattr__(),
__sizeof__(), __str__(), __subclasshook__()
1.9.2
Properties
Name
Inherited from object
__class__
1.10
Description
Class Edge
object
igraph.Edge
105
Class Edge
Package igraph
e["weight"] = 2
print e["weight"]
#doctest: +SKIP
#doctest: +SKIP
1.10.1
Methods
__delitem__(x, y)
del x[y]
__eq__(x, y)
x==y
__ge__(x, y)
x>=y
__getitem__(x, y)
x[y]
__gt__(x, y)
x>y
__hash__(x )
hash(x)
Overrides: object.__hash__
__le__(x, y)
x<=y
__len__(x )
len(x)
106
Class Edge
Package igraph
__lt__(x, y)
x<y
__ne__(x, y)
x!=y
__repr__(x )
repr(x)
Overrides: object.__repr__
__setitem__(x, i, y)
x[i]=y
attribute_names()
Returns the list of edge attribute names
Return Value
list
attributes()
Returns a dict of attribute names and values for the edge
Return Value
dict
count_multiple(...)
Proxy method to Graph.count_multiple()
This method calls the count_multiple method of the Graph class with this
edge as the first argument, and returns the result.
See Also: Graph.count_multiple() for details.
delete(...)
Proxy method to Graph.delete_edges()
This method calls the delete_edges method of the Graph class with this edge
as the first argument, and returns the result.
See Also: Graph.delete_edges() for details.
107
Class Edge
Package igraph
is_loop(...)
Proxy method to Graph.is_loop()
This method calls the is_loop method of the Graph class with this edge as the
first argument, and returns the result.
See Also: Graph.is_loop() for details.
is_multiple(...)
Proxy method to Graph.is_multiple()
This method calls the is_multiple method of the Graph class with this edge as
the first argument, and returns the result.
See Also: Graph.is_multiple() for details.
is_mutual(...)
Proxy method to Graph.is_mutual()
This method calls the is_mutual method of the Graph class with this edge as
the first argument, and returns the result.
See Also: Graph.is_mutual() for details.
update_attributes(E, **F )
Updates the attributes of the edge from dict/iterable E and F.
If E has a keys() method, it does: for k in E: self[k] = E[k]. If E lacks
a keys() method, it does: for (k, v) in E: self[k] = v. In either case,
this is followed by: for k in F: self[k] = F[k].
This method thus behaves similarly to the update() method of Python
dictionaries.
Return Value
None
Inherited from object
__delattr__(), __format__(), __getattribute__(), __init__(), __new__(),
__reduce__(), __reduce_ex__(), __setattr__(), __sizeof__(), __str__(),
__subclasshook__()
1.10.2
Properties
108
Class GraphBase
Package igraph
Name
graph
index
source
target
tuple
Description
The graph the edge belongs to
Index of this edge
Source node index of this edge
Target node index of this edge
Source and target node index of this edge as a
tuple
1.11
Class GraphBase
object
igraph.GraphBase
Known Subclasses: igraph.Graph
Low-level representation of a graph.
Dont use it directly, use igraph.Graph instead.
109
Class GraphBase
1.11.1
Package igraph
Methods
Adjacency(matrix, mode=ADJ_DIRECTED)
Generates a graph from its adjacency matrix.
Parameters
matrix: the adjacency matrix
mode:
110
Class GraphBase
Package igraph
attribute:
loops:
Atlas(idx )
Generates a graph from the Graph Atlas.
Parameters
idx: The index of the graph to be generated. Indices start from
zero, graphs are listed:
1. in increasing order of number of vertices;
2. for a fixed number of vertices, in increasing order of the
number of edges;
3. for fixed numbers of vertices and edges, in increasing order
of the degree sequence, for example 111223 < 112222;
4. for fixed degree sequence, in increasing number of
automorphisms.
Reference: An Atlas of Graphs by Ronald C. Read and Robin J. Wilson,
Oxford University Press, 1998.
111
Class GraphBase
Package igraph
m:
outpref:
directed:
power:
zero_appeal:
112
Class GraphBase
Package igraph
De_Bruijn(m, n)
Generates a de Bruijn graph with parameters (m, n)
A de Bruijn graph represents relationships between strings. An alphabet of m
letters are used and strings of length n are considered. A vertex corresponds
to every possible string and there is a directed edge from vertex v to vertex w
if the string of v can be transformed into the string of w by removing its first
letter and appending a letter to it.
Please note that the graph will have m^n vertices and even more edges, so
probably you dont want to supply too big numbers for m and n.
Parameters
m: the size of the alphabet
n: the length of the strings
113
Class GraphBase
Package igraph
114
Class GraphBase
Package igraph
p:
m:
k:
type_dist:
Famous(name)
Generates a famous graph based on its name.
Several famous graphs are known to igraph including (but not limited to) the
Chvatal graph, the Petersen graph or the Tutte graph. This method generates
one of them based on its name (case insensitive). See the documentation of
the C interface of igraph for the names available: http://igraph.org/doc/c.
Parameters
name: the name of the graph to be generated.
115
Class GraphBase
Package igraph
116
Class GraphBase
Package igraph
117
Class GraphBase
Package igraph
Kautz(m, n)
Generates a Kautz graph with parameters (m, n)
A Kautz graph is a labeled graph, vertices are labeled by strings of length n+1
above an alphabet with m+1 letters, with the restriction that every two
consecutive letters in the string must be different. There is a directed edge
from a vertex v to another vertex w if it is possible to transform the string of v
into the string of w by removing the first letter and appending a letter to it.
Parameters
m: the size of the alphabet minus one
n: the length of the strings minus one
LCF(n, shifts, repeats)
Generates a graph from LCF notation.
LCF is short for Lederberg-Coxeter-Frucht, it is a concise notation for
3-regular Hamiltonian graphs. It consists of three parameters, the number of
vertices in the graph, a list of shifts giving additional edges to a cycle
backbone and another integer giving how many times the shifts should be
performed. See http://mathworld.wolfram.com/LCFNotation.html for details.
Parameters
n:
118
Class GraphBase
Package igraph
type_dist:
directed:
loops:
119
Class GraphBase
Package igraph
120
Class GraphBase
Package igraph
121
Class GraphBase
Package igraph
Read_Pajek(f )
Reads a Pajek format file and creates a graph based on it.
Parameters
f: the name of the file or a Python file handle
122
Class GraphBase
Package igraph
m:
window:
123
Class GraphBase
Package igraph
loops:
124
Class GraphBase
Package igraph
multiple:
Return Value
a directed or undirected graph with the prescribed power-law degree
distributions.
125
Class GraphBase
Package igraph
m:
exponent_out:
exponent_in:
loops:
multiple:
126
Class GraphBase
Package igraph
size:
nei:
p:
rewiring probability
loops:
127
Class GraphBase
Package igraph
attr:
the name of the edge attribute that stores the edge weights.
128
Class GraphBase
Package igraph
__invert__(x )
~x
__new__(T, S, ...)
Return Value
a new object with type S, a subtype of T
Overrides: object.__new__
__or__(x, y)
x|y
__rand__(x, y)
y&x
__ror__(x, y)
y|x
__setitem__(x, i, y)
x[i]=y
__str__(x )
str(x)
Overrides: object.__str__
add_edges(es)
Adds edges to the graph.
Parameters
es: the list of edges to be added. Every edge is represented with a
tuple, containing the vertex IDs of the two endpoints. Vertices
are enumerated from zero.
add_vertices(n)
Adds vertices to the graph.
Parameters
n: the number of vertices to be added
129
Class GraphBase
Package igraph
all_minimal_st_separators()
Returns a list containing all the minimal s-t separators of a graph.
A minimal separator is a set of vertices whose removal disconnects the graph,
while the removal of any subset of the set keeps the graph connected.
Return Value
a list where each item lists the vertex indices of a given minimal s-t
separator.
Reference: Anne Berry, Jean-Paul Bordat and Olivier Cogis: Generating all
the minimal separators of a graph. In: Peter Widmayer, Gabriele Neyer and
Stephan Eidenbenz (eds.): Graph-theoretic concepts in computer science,
1665, 167172, 1999. Springer.
all_st_cuts(source, target)
Returns all the cuts between the source and target vertices in a directed graph.
This function lists all edge-cuts between a source and a target vertex. Every
cut is listed exactly once.
Parameters
source: the source vertex ID
target: the target vertex ID
Return Value
a tuple where the first element is a list of lists of edge IDs
representing a cut and the second element is a list of lists of vertex
IDs representing the sets of vertices that were separated by the cuts.
Attention: this function has a more convenient interface in class Graph which
wraps the result in a list of Cut objects. It is advised to use that.
all_st_mincuts(source, target)
Returns all minimum cuts between the source and target vertices in a directed
graph.
Parameters
source: the source vertex ID
target: the target vertex ID
Attention: this function has a more convenient interface in class Graph which
wraps the result in a list of Cut objects. It is advised to use that.
130
Class GraphBase
Package igraph
are_connected(v1, v2 )
Decides whether two given vertices are directly connected.
Parameters
v1: the first vertex
v2: the second vertex
Return Value
True if there exists an edge from v1 to v2, False otherwise.
articulation_points()
Returns the list of articulation points in the graph.
A vertex is an articulation point if its removal increases the number of
connected components in the graph.
131
Class GraphBase
Package igraph
types2:
132
Class GraphBase
Package igraph
assortativity_degree(directed =True)
Returns the assortativity of a graph based on vertex degrees.
See assortativity() for the details. assortativity_degree() simply calls
assortativity() with the vertex degrees as types.
Parameters
directed: whether to consider edge directions for directed graphs
or not. This argument is ignored for undirected graphs.
Return Value
the assortativity coefficient
See Also: assortativity()
assortativity_nominal(types, directed =True)
Returns the assortativity of the graph based on vertex categories.
Assuming that the vertices belong to different categories, this function
calculates the assortativity coefficient, which specifies the extent to which the
connections stay within categories. The assortativity coefficient is one if all the
connections stay within categories and minus one if all the connections join
vertices of different categories. For a randomly connected network, it is
asymptotically zero.
See equation (2) in Newman MEJ: Mixing patterns in networks, Phys Rev E
67:026126 (2003) for the proper definition.
Parameters
types:
133
Class GraphBase
Package igraph
scale:
arpack_options:
Return Value
the average path length in the graph
134
Class GraphBase
Package igraph
135
Class GraphBase
Package igraph
Class GraphBase
Package igraph
canonical_permutation(sh="fm")
Calculates the canonical permutation of a graph using the BLISS isomorphism
algorithm.
Passing the permutation returned here to Graph.permute_vertices() will
transform the graph into its canonical form.
See http://www.tcs.hut.fi/Software/bliss/index.html for more information
about the BLISS algorithm and canonical permutations.
Parameters
sh: splitting heuristics for graph as a case-insensitive string, with
the following possible values:
"f": first non-singleton cell
"fl": first largest non-singleton cell
"fs": first smallest non-singleton cell
"fm": first maximally non-trivially connected non-singleton
cell
"flm": largest maximally non-trivially connected
non-singleton cell
"fsm": smallest maximally non-trivially connected
non-singleton cell
Return Value
a permutation vector containing vertex IDs. Vertex 0 in the original
graph will be mapped to an ID contained in the first element of this
vector; vertex 1 will be mapped to the second and so on.
clique_number()
Returns the clique number of the graph.
The clique number of the graph is the size of the largest clique.
See Also: largest_cliques() for the largest cliques.
137
Class GraphBase
Package igraph
138
Class GraphBase
Package igraph
mode:
cutoff:
weights:
139
Class GraphBase
Package igraph
clusters(mode=STRONG)
Calculates the (strong or weak) clusters for a given graph.
Parameters
mode: must be either STRONG or WEAK, depending on the clusters
being sought. Optional, defaults to STRONG.
Return Value
the component index for every node in the graph.
Attention: this function has a more convenient interface in class Graph which
wraps the result in a VertexClustering object. It is advised to use that.
cocitation(vertices=None)
Calculates cocitation scores for given vertices in a graph.
Parameters
vertices: the vertices to be analysed. If None, all vertices will be
considered.
Return Value
cocitation scores for all given vertices in a matrix.
cohesive_blocks()
Calculates the cohesive block structure of the graph.
Attention: this function has a more convenient interface in class Graph which
wraps the result in a CohesiveBlocks object. It is advised to use that.
140
Class GraphBase
Package igraph
141
Class GraphBase
Package igraph
community_fastgreedy(weights=None)
Finds the community structure of the graph according to the algorithm of
Clauset et al based on the greedy optimization of modularity.
This is a bottom-up algorithm: initially every vertex belongs to a separate
community, and communities are merged one by one. In every step, the two
communities being merged are the ones which result in the maximal increase
in modularity.
Parameters
weights: name of an edge attribute or a list containing edge weights
Return Value
a tuple with the following elements:
1. The list of merges
2. The modularity scores before each merge
Attention: this function is wrapped in a more convenient syntax in the
derived class Graph. It is advised to use that instead of this version.
Reference: A. Clauset, M. E. J. Newman and C. Moore: Finding community
structure in very large networks. Phys Rev E 70, 066111 (2004).
See Also: modularity()
142
Class GraphBase
Package igraph
community_infomap(edge_weights=None, vertex_weights=None,
trials=10)
Finds the community structure of the network according to the Infomap
method of Martin Rosvall and Carl T. Bergstrom.
See http://www.mapequation.org for a visualization of the algorithm or one of
the references provided below.
Parameters
edge_weights:
Return Value
the calculated membership vector and the corresponding codelength
in a tuple.
Reference:
M. Rosvall and C. T. Bergstrom: Maps of information flow
reveal community structure in complex networks. PNAS 105,
1118 (2008). http://arxiv.org/abs/0707.0609
M. Rosvall, D. Axelsson and C. T. Bergstrom: The map
equation. Eur Phys J Special Topics 178, 13 (2009).
http://arxiv.org/abs/0906.1405
143
Class GraphBase
Package igraph
Return Value
the resulting membership vector
Reference: Raghavan, U.N. and Albert, R. and Kumara, S. Near linear time
algorithm to detect community structures in large-scale networks. Phys Rev E
76:036106, 2007. http://arxiv.org/abs/0709.2938 .
144
Class GraphBase
Package igraph
community_leading_eigenvector(n=-1, arpack_options=None,
weights=None)
A proper implementation of Newmans eigenvector community structure
detection. Each split is done by maximizing the modularity regarding the
original network. See the reference for details.
Parameters
n:
Return Value
a tuple where the first element is the membership vector of the
clustering and the second element is the merge matrix.
Attention: this function is wrapped in a more convenient syntax in the
derived class Graph. It is advised to use that instead of this version.
Reference: MEJ Newman: Finding community structure in networks using
the eigenvectors of matrices, arXiv:physics/0605087
145
Class GraphBase
Package igraph
community_multilevel(weights=None, return_levels=True)
Finds the community structure of the graph according to the multilevel
algorithm of Blondel et al. This is a bottom-up algorithm: initially every
vertex belongs to a separate community, and vertices are moved between
communities iteratively in a way that maximizes the vertices local
contribution to the overall modularity score. When a consensus is reached (i.e.
no single move would increase the modularity score), every community in the
original graph is shrank to a single vertex (while keeping the total weight of
the incident edges) and the process continues on the next level. The algorithm
stops when it is not possible to increase the modularity any more after
shrinking the communities to vertices.
Parameters
weights:
146
Class GraphBase
Package igraph
community_optimal_modularity(weights=None)
Calculates the optimal modularity score of the graph and the corresponding
community structure.
This function uses the GNU Linear Programming Kit to solve a large integer
optimization problem in order to find the optimal modularity score and the
corresponding community structure, therefore it is unlikely to work for graphs
larger than a few (less than a hundred) vertices. Consider using one of the
heuristic approaches instead if you have such a large graph.
Parameters
weights: name of an edge attribute or a list containing edge
weights.
Return Value
the calculated membership vector and the corresponding modularity
in a tuple.
147
Class GraphBase
Package igraph
spins:
parupdate:
start_temp:
stop_temp:
cool_fact:
update_rule:
gamma:
Return Value
the community membership vector.
Class GraphBase
Package igraph
community_walktrap(weights=None, steps=None)
Finds the community structure of the graph according to the random walk
method of Latapy & Pons.
The basic idea of the algorithm is that short random walks tend to stay in the
same community. The method provides a dendrogram.
Parameters
weights: name of an edge attribute or a list containing edge weights
Return Value
a tuple with the list of merges and the modularity scores
corresponding to each merge
Attention: this function is wrapped in a more convenient syntax in the
derived class Graph. It is advised to use that instead of this version.
Reference: Pascal Pons, Matthieu Latapy: Computing communities in large
networks using random walks, http://arxiv.org/abs/physics/0512106 .
See Also: modularity()
complementer(loops=False)
Returns the complementer of the graph
Parameters
loops: whether to include loop edges in the complementer.
Return Value
the complementer of the graph
compose(other )
Returns the composition of two graphs.
149
Class GraphBase
Package igraph
constraint(vertices=None, weights=None)
Calculates Burts constraint scores for given vertices in a graph.
Burts constraint is higher if ego has less, or mutually stronger related (i.e.
more redundant) contacts. Burts measure of constraint, C[i], of vertex is ego
network V[i], is defined for directed and valued graphs as follows:
C[i] = sum( sum( (p[i,q] p[q,j])^2, q in V[i], q != i,j ), j in V[], j != i)
for a graph of order (ie. number od vertices) N, where proportional tie
strengths are defined as follows:
p[i,j]=(a[i,j]+a[j,i]) / sum(a[i,k]+a[k,i], k in V[i], k != i), a[i,j] are elements of
A and the latter being the graph adjacency matrix.
For isolated vertices, constraint is undefined.
Parameters
vertices: the vertices to be analysed or None for all vertices.
weights: weights associated to the edges. Can be an attribute
name as well. If None, every edge will have the same
weight.
Return Value
constraint scores for all given vertices in a matrix.
150
Class GraphBase
Package igraph
contract_vertices(mapping, combine_attrs=None)
Contracts some vertices in the graph, i.e. replaces groups of vertices with
single vertices. Edges are not affected.
Parameters
mapping:
151
Class GraphBase
Package igraph
coreness(mode=ALL)
Finds the coreness (shell index) of the vertices of the network.
The k -core of a graph is a maximal subgraph in which each vertex has at least
degree k. (Degree here means the degree in the subgraph of course). The
coreness of a vertex is k if it is a member of the k -core but not a member of
the k+1 -core.
Parameters
mode: whether to compute the in-corenesses (IN), the out-corenesses
(OUT) or the undirected corenesses (ALL). Ignored and
assumed to be ALL for undirected graphs.
Return Value
the corenesses for each vertex.
Reference: Vladimir Batagelj, Matjaz Zaversnik: An O(m) Algorithm for
Core Decomposition of Networks.
152
Class GraphBase
Package igraph
color1:
color2:
edge_color1:
edge_color2:
Class GraphBase
Package igraph
count_multiple(edges=None)
Counts the multiplicities of the given edges.
Parameters
edges: edge indices for which we want to count their multiplicity. If
None, all edges are counted.
Return Value
the multiplicities of the given edges as a list.
154
Class GraphBase
Package igraph
color1:
color2:
edge_color1:
edge_color2:
Class GraphBase
Package igraph
maxcompno:
loops:
delete_edges(es)
Removes edges from the graph.
All vertices will be kept, even if they lose all their edges. Nonexistent edges
will be silently ignored.
Parameters
es: the list of edges to be removed. Edges are identifed by edge IDs.
EdgeSeq objects are also accepted here.
delete_vertices(vs)
Deletes vertices and all its edges from the graph.
Parameters
vs: a single vertex ID or the list of vertex IDs to be deleted.
156
Class GraphBase
Package igraph
density(loops=False)
Calculates the density of the graph.
Parameters
loops: whether to take loops into consideration. If True, the
algorithm assumes that there might be some loops in the
graph and calculates the density accordingly. If False, the
algorithm assumes that there cant be any loops.
Return Value
the reciprocity of the graph.
diameter(directed =True, unconn=True, weights=None)
Calculates the diameter of the graph.
Parameters
directed: whether to consider directed paths.
unconn:
157
Class GraphBase
Package igraph
diversity(vertices=None, weights=None)
Calculates the structural diversity index of the vertices.
The structural diversity index of a vertex is simply the (normalized) Shannon
entropy of the weights of the edges incident on the vertex.
The measure is defined for undirected graphs only; edge directions are ignored.
Parameters
vertices: the vertices for which the diversity indices must be
returned. If None, uses all of the vertices in the graph.
weights: edge weights to be used. Can be a sequence or iterable or
even an edge attribute name.
Return Value
the calculated diversity indices in a list, or a single number if a single
vertex was supplied.
Reference: Eagle N, Macy M and Claxton R: Network diversity and
economic development, Science 328, 10291031, 2010.
dyad_census()
Dyad census, as defined by Holland and Leinhardt
Dyad census means classifying each pair of vertices of a directed graph into
three categories: mutual, there is an edge from a to b and also from b to a;
asymmetric, there is an edge either from a to b or from b to a but not the
other way and null, no edges between a and b.
Return Value
the number of mutual, asymmetric and null connections in a 3-tuple.
Attention: this function has a more convenient interface in class Graph which
wraps the result in a DyadCensus object. It is advised to use that.
158
Class GraphBase
Package igraph
eccentricity(vertices=None, mode=ALL)
Calculates the eccentricities of given vertices in a graph.
The eccentricity of a vertex is calculated by measuring the shortest distance
from (or to) the vertex, to (or from) all other vertices in the graph, and taking
the maximum.
Parameters
vertices: the vertices for which the eccentricity scores must be
returned. If None, uses all of the vertices in the graph.
mode:
Return Value
the calculated eccentricities in a list, or a single number if a single
vertex was supplied.
ecount()
Counts the number of edges.
Return Value
the number of edges in the graph.
(type=integer)
edge_attributes()
Return Value
the attribute name list of the graphs edges
159
Class GraphBase
Package igraph
160
Class GraphBase
Package igraph
scale:
weights:
Return Value
the eigenvector centralities in a list and optionally the largest
eigenvalue (as a second member of a tuple)
farthest_points(directed =True, unconn=True, weights=None)
Returns two vertex IDs whose distance equals the actual diameter of the graph.
If there are many shortest paths with the length of the diameter, it returns the
first one it found.
Parameters
directed: whether to consider directed paths.
unconn:
161
Class GraphBase
Package igraph
162
Class GraphBase
Package igraph
163
Class GraphBase
Package igraph
Return Value
the edge ID of an arbitrary edge between vertices v1 and v2
get_eids(pairs=None, path=None, directed =True, error =True)
Returns the edge IDs of some edges between some vertices.
This method can operate in two different modes, depending on which of the
keyword arguments pairs and path are given.
The method does not consider multiple edges; if there are multiple edges
between a pair of vertices, only the ID of one of the edges is returned.
Parameters
pairs:
path:
Return Value
the edge IDs in a list
164
Class GraphBase
Package igraph
get_incidence(types)
Internal function, undocumented.
See Also: Graph.get_incidence()
165
Class GraphBase
Package igraph
color1:
color2:
edge_color1:
edge_color2:
Class GraphBase
Package igraph
167
Class GraphBase
Package igraph
domains:
induced:
168
Class GraphBase
Package igraph
color1:
color2:
edge_color1:
edge_color2:
Return Value
a list of lists, each item of the list containing the mapping from
vertices of the second graph to the vertices of the first one
Class GraphBase
Package igraph
girth(return_shortest_circle=False)
Returns the girth of the graph.
The girth of a graph is the length of the shortest circle in it.
Parameters
return_shortest_circle: whether to return one of the shortest
circles found in the graph.
Return Value
the length of the shortest circle or (if return_shortest_circle) is
true, the shortest circle itself as a list
gomory_hu_tree(capacity=None)
Internal function, undocumented.
See Also: Graph.gomory_hu_tree()
has_multiple()
Checks whether the graph has multiple edges.
Return Value
True if the graph has at least one multiple edge, False otherwise.
(type=boolean)
170
Class GraphBase
Package igraph
scale:
arpack_options:
independence_number()
Returns the independence number of the graph.
The independence number of the graph is the size of the largest independent
vertex set.
See Also: largest_independent_vertex_sets() for the largest independent
vertex sets
171
Class GraphBase
Package igraph
172
Class GraphBase
Package igraph
is_bipartite(return_types=False)
Decides whether the graph is bipartite or not.
Vertices of a bipartite graph can be partitioned into two groups A and B in a
way that all edges go between the two groups.
Parameters
return_types: if False, the method will simply return True or
False depending on whether the graph is bipartite
or not. If True, the actual group assignments are
also returned as a list of boolean values. (Note that
the group assignment is not unique, especially if the
graph consists of multiple components, since the
assignments of components are independent from
each other).
Return Value
True if the graph is bipartite, False if not. If return_types is True,
the group assignment is also returned.
is_connected(mode=STRONG)
Decides whether the graph is connected.
Parameters
mode: whether we should calculate strong or weak connectivity.
Return Value
True if the graph is connected, False otherwise.
is_dag()
Checks whether the graph is a DAG (directed acyclic graph).
A DAG is a directed graph with no directed cycles.
Return Value
True if it is a DAG, False otherwise.
(type=boolean)
is_directed()
Checks whether the graph is directed.@return: True if it is directed, False
otherwise.
Return Value
boolean
173
Class GraphBase
Package igraph
is_loop(edges=None)
Checks whether a specific set of edges contain loop edges
Parameters
edges: edge indices which we want to check. If None, all edges are
checked.
Return Value
a list of booleans, one for every edge given
is_minimal_separator(vertices)
Decides whether the given vertex set is a minimal separator.
A minimal separator is a set of vertices whose removal disconnects the graph,
while the removal of any subset of the set keeps the graph connected.
Parameters
vertices: a single vertex ID or a list of vertex IDs
Return Value
True is the given vertex set is a minimal separator, False otherwise.
is_multiple(edges=None)
Checks whether an edge is a multiple edge.
Also works for a set of edges in this case, every edge is checked one by one.
Note that if there are multiple edges going between a pair of vertices, there is
always one of them that is not reported as multiple (only the others). This
allows one to easily detect the edges that have to be deleted in order to make
the graph free of multiple edges.
Parameters
edges: edge indices which we want to check. If None, all edges are
checked.
Return Value
a list of booleans, one for every edge given
174
Class GraphBase
Package igraph
is_mutual(edges=None)
Checks whether an edge has an opposite pair.
Also works for a set of edges in this case, every edge is checked one by one.
The result will be a list of booleans (or a single boolean if only an edge index
is supplied), every boolean corresponding to an edge in the edge set supplied.
True is returned for a given edge a > b if there exists another edge b > a in
the original graph (not the given edge set!). All edges in an undirected graph
are mutual. In case there are multiple edges between a and b, it is enough to
have at least one edge in either direction to report all edges between them as
mutual, so the multiplicity of edges do not matter.
Parameters
edges: edge indices which we want to check. If None, all edges are
checked.
Return Value
a list of booleans, one for every edge given
is_separator(vertices)
Decides whether the removal of the given vertices disconnects the graph.
Parameters
vertices: a single vertex ID or a list of vertex IDs
Return Value
True is the given vertex set is a separator, False if not.
is_simple()
Checks whether the graph is simple (no loop or multiple edges).
Return Value
True if it is simple, False otherwise.
(type=boolean)
175
Class GraphBase
Package igraph
isoclass(vertices)
Returns the isomorphy class of the graph or its subgraph.
Isomorphy class calculations are implemented only for graphs with 3 or 4
vertices.
Parameters
vertices: a list of vertices if we want to calculate the isomorphy
class for only a subset of vertices. None means to use the
full graph.
Return Value
the isomorphy class of the (sub)graph
isomorphic(other )
Checks whether the graph is isomorphic to another graph.
The algorithm being used is selected using a simple heuristic:
If one graph is directed and the other undirected, an exception is thrown.
If the two graphs does not have the same number of vertices and edges, it
returns with False
If the graphs have three or four vertices, then an O(1) algorithm is used
with precomputed data.
Otherwise if the graphs are directed, then the VF2 isomorphism
algorithm is used (see Graph.isomorphic_vf2).
Otherwise the BLISS isomorphism algorithm is used, see
Graph.isomorphic_bliss.
Return Value
True if the graphs are isomorphic, False otherwise.
176
Class GraphBase
Package igraph
sh2:
Return Value
if no mapping is calculated, the result is True if the graphs are
isomorphic, False otherwise. If any or both mappings are
calculated, the result is a 3-tuple, the first element being the above
mentioned boolean, the second element being the 1 -> 2 mapping
and the third element being the 2 -> 1 mapping. If the
corresponding mapping was not calculated, None is returned in the
appropriate element of the 3-tuple.
177
Class GraphBase
Package igraph
color1:
color2:
edge_color1:
edge_color2:
node_compat_fn:
Class GraphBase
Package igraph
knn(vids=None, weights=None)
Calculates the average degree of the neighbors for each vertex, and the same
quantity as the function of vertex degree.
Parameters
vids:
179
Class GraphBase
Package igraph
largest_cliques()
Returns the largest cliques of the graph as a list of tuples.
Quite intuitively a clique is considered largest if there is no clique with more
vertices in the whole graph. All largest cliques are maximal (i.e.
nonextendable) but not all maximal cliques are largest.
See Also: clique_number() for the size of the largest cliques or
maximal_cliques() for the maximal cliques
largest_independent_vertex_sets()
Returns the largest independent vertex sets of the graph as a list of tuples.
Quite intuitively an independent vertex set is considered largest if there is no
other set with more vertices in the whole graph. All largest sets are maximal
(i.e. nonextendable) but not all maximal sets are largest.
See Also: independence_number() for the size of the largest independent
vertex sets or maximal_independent_vertex_sets() for the maximal
(nonextendable) independent vertex sets
layout_bipartite(types="type", hgap=1, vgap=1, maxiter =100)
Place the vertices of a bipartite graph in two layers.
The layout is created by placing the vertices in two rows, according to their
types. The positions of the vertices within the rows are then optimized to
minimize the number of edge crossings using the heuristic used by the
Sugiyama layout algorithm.
Parameters
types:
hgap:
vgap:
180
Class GraphBase
Package igraph
layout_circle(dim=2)
Places the vertices of the graph uniformly on a circle or a sphere.
Parameters
dim: the desired number of dimensions for the layout. dim=2 means
a 2D layout, dim=3 means a 3D layout.
Return Value
the calculated layout.
181
Class GraphBase
Package igraph
fixed:
options: if you give a string argument here, you can select from five
default preset parameterisations: default, coarsen for a
coarser layout, coarsest for an even coarser layout,
refine for refining an existing layout and final for
finalizing a layout. If you supply an object that is not a
string, the DrL layout parameters are retrieved from the
respective keys of the object (so it should be a dict or
something else that supports the mapping protocol). The
following keys can be used:
edge_cut: edge cutting is done in the late stages of
the algorithm in order to achieve less dense layouts.
Edges are cut if there is a lot of stress on them (a large
value in the objective function sum). The edge cutting
parameter is a value between 0 and 1 with 0
representing no edge cutting and 1 representing
maximal edge cutting.
init_iterations: number of iterations in the
initialization phase
init_temperature: start temperature during
initialization
init_attraction: attraction during initialization
init_damping_mult: damping multiplier during
initialization
182
liquid_iterations, liquid_temperature,
liquid_attraction, liquid_damping_mult: same
parameters for the liquid phase
expansion_iterations, expansion_temperature,
Class GraphBase
Package igraph
maxiter:
maxdelta:
area:
coolexp:
maxx:
miny:
maxy:
minz:
maxz:
seed:
dim:
Return Value
the calculated layout.
Class GraphBase
Package igraph
node_charge:
node_mass:
spring_length:
Return Value
the calculated layout.
184
Class GraphBase
Package igraph
Return Value
the calculated layout.
185
Class GraphBase
Package igraph
maxdelta:
area:
coolexp:
seed:
Return Value
the calculated layout.
186
Class GraphBase
Package igraph
maxx:
miny:
maxy:
minz:
maxz:
seed:
dim:
Return Value
the calculated layout.
187
Class GraphBase
Package igraph
maxdelta:
area:
coolexp:
root:
Return Value
the calculated layout.
188
Class GraphBase
Package igraph
dim:
189
Class GraphBase
Package igraph
root:
190
Class GraphBase
Package igraph
layout_reingold_tilford_circular(mode="out", root=None,
rootlevel =None)
Circular Reingold-Tilford layout for trees.
This layout is similar to the Reingold-Tilford layout, but the vertices are
placed in a circular way, with the root vertex in the center.
See layout_reingold_tilford for the explanation of the parameters.
Return Value
the calculated layout.
See Also: layout_reingold_tilford
Reference: EM Reingold, JS Tilford: Tidier Drawings of Trees. IEEE
Transactions on Software Engineering 7:22, 223-228, 1981.
layout_star(center =0, order =None)
Calculates a star-like layout for the graph.
Parameters
center: the ID of the vertex to put in the center
order: a numeric vector giving the order of the vertices (including
the center vertex!). If it is None, the vertices will be placed
in increasing vertex ID order.
Return Value
the calculated layout.
linegraph()
Returns the line graph of the graph.
The line graph L(G) of an undirected graph is defined as follows: L(G) has
one vertex for each edge in G and two vertices in L(G) are connected iff their
corresponding edges in the original graph share an end point.
The line graph of a directed graph is slightly different: two vertices are
connected by a directed edge iff the target of the first vertexs corresponding
edge is the same as the source of the second vertexs corresponding edge.
191
Class GraphBase
Package igraph
loops:
target:
192
Class GraphBase
Package igraph
target:
193
Class GraphBase
Package igraph
target:
194
Class GraphBase
Package igraph
target:
195
Class GraphBase
Package igraph
modularity(membership, weights=None)
Calculates the modularity of the graph with respect to some vertex types.
The modularity of a graph w.r.t. some division measures how good the
division is, or how separated are the different vertex types from each other. It
is defined as Q=1/(2m) * sum(Aij-ki*kj/(2m)delta(ci,cj),i,j). m is the number
of edges, Aij is the element of the A adjacency matrix in row i and column j,
ki is the degree of node i, kj is the degree of node j, and Ci and cj are the
types of the two vertices (i and j ). delta(x,y) is one iff x=y, 0 otherwise.
If edge weights are given, the definition of modularity is modified as follows:
Aij becomes the weight of the corresponding edge, ki is the total weight of
edges incident on vertex i, kj is the total weight of edges incident on vertex j
and m is the total edge weight in the graph.
Parameters
membership: the membership vector, e.g. the vertex type index for
each vertex.
weights:
Return Value
the modularity score. Score larger than 0.3 usually indicates strong
community structure.
Attention: method overridden in Graph to allow VertexClustering objects
as a parameter. This method is not strictly necessary, since the
VertexClustering class provides a variable called modularity.
Reference: MEJ Newman and M Girvan: Finding and evaluating community
structure in networks. Phys Rev E 69 026113, 2004.
196
Class GraphBase
Package igraph
cut_prob: the cut probabilities for different levels of the search tree.
This must be a list of length size or None to find all
motifs.
callback: None or a callable that will be called for every motif
found in the graph. The callable must accept three
parameters: the graph itself, the list of vertices in the
motif and the isomorphy class of the motif (see
Graph.isoclass()). The search will stop when the
callback returns an object with a non-zero truth value or
raises an exception.
Return Value
the list of motifs if callback is None, or None otherwise
Reference: S. Wernicke and F. Rasche: FANMOD: a tool for fast network
motif detection, Bioinformatics 22(9), 11521153, 2006.
See Also: Graph.motifs_randesu_no()
197
Class GraphBase
Package igraph
cut_prob: the cut probabilities for different levels of the search tree.
This must be a list of length size or None to find all
motifs.
sample:
cut_prob: the cut probabilities for different levels of the search tree.
This must be a list of length size or None to find all
motifs.
Reference: S. Wernicke and F. Rasche: FANMOD: a tool for fast network
motif detection, Bioinformatics 22(9), 11521153, 2006.
See Also: Graph.motifs_randesu()
198
Class GraphBase
Package igraph
Return Value
a single list specifying the neighborhood if vertices was an integer
specifying a single vertex index, or a list of lists if vertices was a list
or None.
neighborhood_size(vertices=None, order =1, mode=ALL)
For each vertex specified by vertices, returns the number of vertices reachable
from that vertex in at most order steps.
Parameters
vertices: a single vertex ID or a list of vertex IDs, or None
meaning all the vertices in the graph.
mode:
Return Value
a single number specifying the neighborhood size if vertices was an
integer specifying a single vertex index, or a list of sizes if vertices
was a list or None.
199
Class GraphBase
Package igraph
neighbors(vertex, mode=ALL)
Returns adjacent vertices to a given vertex.
Parameters
vertex: a vertex ID
mode:
path_length_hist(directed =True)
Calculates the path length histogram of the graph
Parameters
directed: whether to consider directed paths
Return Value
a tuple. The first item of the tuple is a list of path lengths, the ith
element of the list contains the number of paths with length i+1.
The second item contains the number of unconnected vertex pairs as
a float (since it might not fit into an integer)
Attention: this function is wrapped in a more convenient syntax in the
derived class Graph. It is advised to use that instead of this version.
permute_vertices(permutation)
Permutes the vertices of the graph according to the given permutation and
returns the new graph.
Vertex k of the original graph will become vertex permutation[k] in the new
graph. No validity checks are performed on the permutation vector.
Return Value
the new graph
200
Class GraphBase
Package igraph
directed:
damping:
reset:
Class GraphBase
Package igraph
predecessors(vertex )
Returns the predecessors of a given vertex.
Equivalent to calling the Graph.neighbors method with type=IN.
radius(mode=OUT)
Calculates the radius of the graph.
The radius of a graph is defined as the minimum eccentricity of its vertices
(see eccentricity()).
Parameters
mode: what kind of paths to consider for the calculation in case of
directed graphs. OUT considers paths that follow edge
directions, IN considers paths that follow the opposite edge
directions, ALL ignores edge directions. The argument is
ignored for undirected graphs.
Return Value
the radius@see: Graph.eccentricity()
reciprocity(ignore_loops=True, mode="default")
Reciprocity defines the proportion of mutual connections in a directed graph.
It is most commonly defined as the probability that the opposite counterpart
of a directed edge is also included in the graph. This measure is calculated if
mode is "default".
Prior to igraph 0.6, another measure was implemented, defined as the
probability of mutual connection between a vertex pair if we know that there
is a (possibly non-mutual) connection between them. In other words,
(unordered) vertex pairs are classified into three groups: (1) disconnected, (2)
non-reciprocally connected and (3) reciprocally connected. The result is the
size of group (3), divided by the sum of sizes of groups (2) and (3). This
measure is calculated if mode is "ratio".
Parameters
ignore_loops: whether loop edges should be ignored.
mode:
Return Value
the reciprocity of the graph
202
Class GraphBase
Package igraph
rewire(n=1000, mode="simple")
Randomly rewires the graph while preserving the degree distribution.
Please note that the rewiring is done "in-place", so the original graph will be
modified. If you want to preserve the original graph, use the copy method
before.
Parameters
n:
the number of rewiring trials.
mode: the rewiring algorithm to use. It can either be "simple" or
"loops"; the former does not create or destroy loop edges
while the latter does.
rewire_edges(prob, loops=False, multiple=False)
Rewires the edges of a graph with constant probability.
Each endpoint of each edge of the graph will be rewired with a constant
probability, given in the first argument.
Please note that the rewiring is done "in-place", so the original graph will be
modified. If you want to preserve the original graph, use the copy method
before.
Parameters
prob:
loops:
rewiring probability
whether the algorithm is allowed to create loop edges
203
Class GraphBase
Package igraph
Return Value
the shortest path lengths for given vertices in a matrix
204
Class GraphBase
Package igraph
mode:
loops:
Return Value
the pairwise similarity coefficients for the vertices specified, in the
form of a matrix if pairs is None or in the form of a list if pairs is
not None.
205
Class GraphBase
Package igraph
similarity_inverse_log_weighted(vertices=None, mode=IGRAPH_ALL)
Inverse log-weighted similarity coefficient of vertices.
Each vertex is assigned a weight which is 1 / log(degree). The log-weighted
similarity of two vertices is the sum of the weights of their common neighbors.
Parameters
vertices: the vertices to be analysed. If None, all vertices will be
considered.
mode:
Return Value
the pairwise similarity coefficients for the vertices specified, in the
form of a matrix (list of lists).
206
Class GraphBase
Package igraph
mode:
loops:
Return Value
the pairwise similarity coefficients for the vertices specified, in the
form of a matrix if pairs is None or in the form of a list if pairs is
not None.
207
Class GraphBase
Package igraph
Class GraphBase
Package igraph
target:
loops:
209
Class GraphBase
Package igraph
subcomponent(v, mode=ALL)
Determines the indices of vertices which are in the same component as a given
vertex.
Parameters
v:
the index of the vertex used as the source/destination
mode: if equals to IN, returns the vertex IDs from where the given
vertex can be reached. If equals to OUT, returns the vertex
IDs which are reachable from the given vertex. If equals to
ALL, returns all vertices within the same component as the
given vertex, ignoring edge directions. Note that this is not
equal to calculating the union of the results of IN and OUT.
Return Value
the indices of vertices which are in the same component as a given
vertex.
subgraph_edges(edges, delete_vertices=True)
Returns a subgraph spanned by the given edges.
Parameters
edges:
210
Class GraphBase
Package igraph
domains:
induced:
time_limit:
211
Class GraphBase
Package igraph
color1:
color2:
edge_color1:
edge_color2:
node_compat_fn:
Class GraphBase
Package igraph
successors(vertex )
Returns the successors of a given vertex.
Equivalent to calling the Graph.neighbors method with type=OUT.
to_directed(mutual =True)
Converts an undirected graph to directed.
Parameters
mutual: True if mutual directed edges should be created for every
undirected edge. If False, a directed edge with arbitrary
direction is created.
to_undirected(mode="collapse", combine_edges=None)
Converts a directed graph to undirected.
Parameters
mode:
213
Class GraphBase
Package igraph
transitivity_avglocal_undirected(mode="nan")
Calculates the average of the vertex transitivities of the graph.
The transitivity measures the probability that two neighbors of a vertex are
connected. In case of the average local transitivity, this probability is
calculated for each vertex and then the average is taken. Vertices with less
than two neighbors require special treatment, they will either be left out from
the calculation or they will be considered as having zero transitivity,
depending on the mode parameter.
Note that this measure is different from the global transitivity measure (see
transitivity_undirected()) as it simply takes the average local transitivity
across the whole network.
Parameters
mode: defines how to treat vertices with degree less than two. If
TRANSITIVITT_ZERO or "zero", these vertices will have zero
transitivity. If TRANSITIVITY_NAN or "nan", these vertices
will be excluded from the average.
See Also: transitivity_undirected(),
transitivity_local_undirected()
Reference: D. J. Watts and S. Strogatz: Collective dynamics of small-world
networks. Nature 393(6884):440-442, 1998.
214
Class GraphBase
Package igraph
transitivity_local_undirected(vertices=None, mode="nan",
weights=None)
Calculates the local transitivity (clustering coefficient) of the given vertices in
the graph.
The transitivity measures the probability that two neighbors of a vertex are
connected. In case of the local transitivity, this probability is calculated
separately for each vertex.
Note that this measure is different from the global transitivity measure (see
transitivity_undirected()) as it calculates a transitivity value for each
vertex individually.
The traditional local transitivity measure applies for unweighted graphs only.
When the weights argument is given, this function calculates the weighted
local transitivity proposed by Barrat et al (see references).
Parameters
vertices: a list containing the vertex IDs which should be included
in the result. None means all of the vertices.
mode:
215
Class GraphBase
Package igraph
transitivity_undirected(mode="nan")
Calculates the global transitivity (clustering coefficient) of the graph.
The transitivity measures the probability that two neighbors of a vertex are
connected. More precisely, this is the ratio of the triangles and connected
triplets in the graph. The result is a single real number. Directed graphs are
considered as undirected ones.
Note that this measure is different from the local transitivity measure (see
transitivity_local_undirected()) as it calculates a single value for the
whole graph.
Parameters
mode: if TRANSITIVITY_ZERO or "zero", the result will be zero if
the graph does not have any triplets. If "nan" or
TRANSITIVITY_NAN, the result will be NaN (not a number).
Return Value
the transitivity
See Also: transitivity_local_undirected(),
transitivity_avglocal_undirected()
Reference: S. Wasserman and K. Faust: Social Network Analysis: Methods
and Applications. Cambridge: Cambridge University Press, 1994.
triad_census()
Triad census, as defined by Davis and Leinhardt
Calculating the triad census means classifying every triplets of vertices in a
directed graph. A triplet can be in one of 16 states, these are listed in the
documentation of the C interface of igraph.
Attention: this function has a more convenient interface in class Graph which
wraps the result in a TriadCensus object. It is advised to use that. The name
of the triplet classes are also documented there.
216
Class GraphBase
Package igraph
unfold_tree(sources=None, mode=OUT)
Unfolds the graph using a BFS to a tree by duplicating vertices as necessary.
Parameters
sources: the source vertices to start the unfolding from. It should
be a list of vertex indices, preferably one vertex from each
connected component. You can use
Graph.topological_sorting() to determine a suitable
set. A single vertex index is also accepted.
mode:
Return Value
the unfolded tree graph and a mapping from the new vertex indices
to the old ones.
union(graphs)
Creates the union of two (or more) graphs.
Parameters
graphs: the list of graphs to be united with the current one.
vcount()
Counts the number of vertices.
Return Value
the number of vertices in the graph.
(type=integer)
vertex_attributes()
Return Value
the attribute name list of the graphs vertices
217
Class GraphBase
Package igraph
target:
checks:
218
Class GraphBase
Package igraph
source:
target:
write_edgelist(f )
Writes the edge list of a graph to a file.
Directed edges are written in (from, to) order.
Parameters
f: the name of the file to be written or a Python file handle
write_gml(f, creator =None, ids=None)
Writes the graph in GML format to the given file.
Parameters
f:
219
Class GraphBase
Package igraph
write_graphml(f )
Writes the graph to a GraphML file.
Parameters
f: the name of the file to be written or a Python file handle
write_leda(f, names="name", weights="weights")
Writes the graph to a file in LEDA native format.
The LEDA format supports at most one attribute per vertex and edge. You
can specify which vertex and edge attribute you want to use. Note that the
name of the attribute is not saved in the LEDA file.
Parameters
f:
names:
weights: the name of the edge attribute to be stored along with the
edges. It is usually used to store the edge weights (hence
the name of the keyword argument), but you may also use
a string attribute. If you dont want to store any edge
attributes, supply None here.
write_lgl(f, names="name", weights="weights", isolates=True)
Writes the edge list of a graph to a file in .lgl format.
Note that multiple edges and/or loops break the LGL software, but igraph
does not check for this condition. Unless you know that the graph does not
have multiple edges and/or loops, it is wise to call simplify() before saving.
Parameters
f:
names:
220
Class GraphBase
Package igraph
Properties
Name
Inherited from object
__class__
Description
221
Module igraph._igraph
Module igraph._igraph
Low-level Python interface for the igraph library. Should not be used directly.
Version: 0.7.0
2.1
Functions
convex_hull(vs, coords=False)
Calculates the convex hull of a given point set.
Parameters
vs:
the point set as a list of lists
coords: if True, the function returns the coordinates of the corners
of the convex hull polygon, otherwise returns the corner
indices.
Return Value
either the hulls corner coordinates or the point indices
corresponding to them, depending on the coords parameter.
222
Functions
Module igraph._igraph
is_degree_sequence(out_deg, in_deg=None)
Returns whether a list of degrees can be a degree sequence of some graph.
Note that it is not required for the graph to be simple; in other words, this
function may return True for degree sequences that can be realized using one
or more multiple or loop edges only.
In particular, this function checks whether
all the degrees are non-negative
for undirected graphs, the sum of degrees are even
for directed graphs, the two degree sequences are of the same length and
equal sums
Parameters
out_deg: the list of degrees. For directed graphs, this list must
contain the out-degrees of the vertices.
in_deg: the list of in-degrees for directed graphs. This parameter
must be None for undirected graphs.
Return Value
True if there exists some graph that can realize the given degree
sequence, False otherwise.@see: is_graphical_degree_sequence()
if you do not want to allow multiple or loop edges.
is_graphical_degree_sequence(out_deg, in_deg=None)
Returns whether a list of degrees can be a degree sequence of some simple
graph.
Note that it is required for the graph to be simple; in other words, this
function will return False for degree sequences that cannot be realized
without using one or more multiple or loop edges.
Parameters
out_deg: the list of degrees. For directed graphs, this list must
contain the out-degrees of the vertices.
in_deg: the list of in-degrees for directed graphs. This parameter
must be None for undirected graphs.
Return Value
True if there exists some simple graph that can realize the given
degree sequence, False otherwise.
See Also: is_degree_sequence() if you want to allow multiple or loop edges.
223
Variables
Module igraph._igraph
set_progress_handler(handler )
Sets the handler to be called when igraph is performing a long operation.
Parameters
handler: the progress handler function. It must accept two
arguments, the first is the message informing the user
about what igraph is doing right now, the second is the
actual progress information (a percentage).
set_random_number_generator(generator )
Sets the random number generator used by igraph.
Parameters
generator: the generator to be used. It must be a Python object
with at least three attributes: random, randint and
gauss. Each of them must be callable and their
signature and behaviour must be identical to
random.random, random.randint and random.gauss.
By default, igraph uses the random module for random
number generation, but you can supply your alternative
implementation here. If the given generator is None,
igraph reverts to the default Mersenne twister generator
implemented in the C layer, which might be slightly
faster than calling back to Python for random numbers,
but you cannot set its seed or save its state.
set_status_handler(handler )
Sets the handler to be called when igraph tries to display a status message.
This is used to communicate the progress of some calculations where no
reasonable progress percentage can be given (so it is not possible to use the
progress handler).
Parameters
handler: the status handler function. It must accept a single
argument, the message that informs the user about what
igraph is doing right now.
2.2
Variables
Name
ADJ_DIRECTED
ADJ_LOWER
Description
Value: 0
Value: 3
continued on next page
224
Variables
Name
ADJ_MAX
ADJ_MIN
ADJ_PLUS
ADJ_UNDIRECTED
ADJ_UPPER
ALL
BLISS_F
BLISS_FL
BLISS_FLM
BLISS_FM
BLISS_FS
BLISS_FSM
GET_ADJACENCY_BOTH
GET_ADJACENCY_LOWER
GET_ADJACENCY_UPPER
IN
OUT
REWIRING_SIMPLE
REWIRING_SIMPLE_LOOPS
STAR_IN
STAR_MUTUAL
STAR_OUT
STAR_UNDIRECTED
STRONG
TRANSITIVITY_NAN
TRANSITIVITY_ZERO
TREE_IN
TREE_OUT
TREE_UNDIRECTED
WEAK
__build_date__
__package__
arpack_options
Module igraph._igraph
Description
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
1
4
5
1
2
3
0
1
4
3
2
5
2
Value: 1
Value: 0
Value:
Value:
Value:
Value:
2
1
0
1
Value: 1
Value: 3
Value: 0
Value: 2
Value: 2
Value: 0
Value: 1
Value: 1
Value: 0
Value: 2
Value: 1
Value: Apr 24 2014
Value: None
Value: <igraph.ARPACKOptions object at
0x7fc6738b8cd0>
225
Class InternalError
2.3
Module igraph._igraph
Class InternalError
object
exceptions.BaseException
exceptions.Exception
igraph._igraph.InternalError
2.3.1
Methods
Properties
Name
Inherited from exceptions.BaseException
args, message
Inherited from object
__class__
226
Description
Variables
Package igraph.app
Package igraph.app
Modules
Variables
Name
__package__
Description
Value: None
227
Class TerminalController
Module igraph.app.shell
Module igraph.app.shell
Functions
main()
The main entry point for igraph when invoked from the command line shell
4.2
Variables
Name
__package__
4.3
Description
Value: igraph.app
Class TerminalController
term = TerminalController()
print This is +term.GREEN+green+term.NORMAL
228
Class TerminalController
Module igraph.app.shell
This is green
Alternatively, the render() method can used, which replaces ${action} with the string
required to perform action:
>>>
term = TerminalController()
term.render(This is ${GREEN}green${NORMAL})
This is green
If the terminal doesnt support a given action, then the value of the corresponding instance
variable will be set to . As a result, the above code will still work on terminals that do not
support color, except that their output will not be colored. Also, this means that you can
test whether the terminal supports a given action by simply testing the truth value of the
corresponding instance variable:
>>>
term = TerminalController()
term.CLEAR_SCREEN:
>>> if
...
...
Finally, if the width and height of the terminal are known, then they will be stored in the
COLS and LINES attributes.
Author: Edward Loper
4.3.1
Methods
__init__(self, term_stream=sys.stdout)
Create a TerminalController and initialize its attributes with appropriate
values for the current terminal. term_stream is the stream that will be used
for terminal output; if this stream is not a tty, then the terminal is assumed to
be a dumb terminal (i.e., have no capabilities).
render(self, template)
Replace each $-substitutions in the given template string with the
corresponding terminal control string (if its defined) or (if its not).
4.3.2
Class Variables
Name
BOL
Description
Move the cursor to the beginning of the line
Value:
continued on next page
229
Class TerminalController
Name
UP
DOWN
LEFT
RIGHT
CLEAR_SCREEN
CLEAR_EOL
CLEAR_BOL
CLEAR_EOS
BOLD
BLINK
DIM
REVERSE
NORMAL
HIDE_CURSOR
SHOW_CURSOR
COLS
LINES
WHITE
YELLOW
MAGENTA
RED
CYAN
GREEN
BLUE
BLACK
Module igraph.app.shell
Description
Move the cursor up one line
Value:
Move the cursor down one line
Value:
Move the cursor left one char
Value:
Move the cursor right one char
Value:
Clear the screen and move to home position
Value:
Clear to the end of the line.
Value:
Clear to the beginning of the line.
Value:
Clear to the end of the screen
Value:
Turn on bold mode
Value:
Turn on blink mode
Value:
Turn on half-bright mode
Value:
Turn on reverse-video mode
Value:
Turn off all modes
Value:
Make the cursor invisible
Value:
Make the cursor visible
Value:
Width of the terminal (None for unknown)
Value: None
Height of the terminal (None for unknown)
Value: None
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
continued on next page
230
Class ProgressBar
Name
BG_CYAN
BG_GREEN
BG_BLUE
BG_BLACK
BG_WHITE
BG_YELLOW
BG_MAGENTA
BG_RED
4.4
Module igraph.app.shell
Description
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Value:
Class ProgressBar
Methods
__init__(self, term)
update(self, percent=None, message=None)
Updates the progress bar.
Parameters
percent: the percentage to be shown. If None, the previous value
will be used.
message: the message to be shown above the progress bar. If None,
the previous message will be used.
update_message(self, message)
Updates the message of the progress bar.
Parameters
message: the message to be shown above the progress bar
clear(self )
Clears the progress bar (i.e. removes it from the screen)
231
Class Shell
4.4.2
Module igraph.app.shell
Class Variables
Name
BAR
HEADER
4.4.3
Instance Variables
Name
cleared
4.5
Description
Value: %3d%%
${GREEN}[${BOLD}%s%s${NORMAL}${GREEN}]${NORMAL}
Value: ${BOLD}${CYAN}%s${NORMAL}\n
Description
true if we havent drawn the bar yet.
Class Shell
object
igraph.app.shell.Shell
Methods
__init__(self )
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: object.__init__ extit(inherited documentation)
__call__(self )
supports_progress_bar(self )
Checks whether the shell supports progress bars.
This is done by checking for the existence of an attribute called
_progress_handler.
232
Class IDLEShell
Module igraph.app.shell
supports_status_messages(self )
Checks whether the shell supports status messages.
This is done by checking for the existence of an attribute called
_status_handler.
get_progress_handler(self )
Returns the progress handler (if exists) or None (if not).
get_status_handler(self )
Returns the status handler (if exists) or None (if not).
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__str__(), __subclasshook__()
4.5.2
Properties
Name
Inherited from object
__class__
4.6
Description
Class IDLEShell
object
igraph.app.shell.Shell
igraph.app.shell.IDLEShell
IDLE embedded shell interface.
This class allows igraph to be embedded in IDLE (the Tk Python IDE).
To Do: no progress bar support yet. Shell/Restart Shell command should re-import igraph
again.
233
Class ConsoleProgressBarMixin
4.6.1
Module igraph.app.shell
Methods
__init__(self )
Constructor.
Imports IDLEs embedded shell. The implementation of this method is ripped
from idlelib.PyShell.main() after removing the unnecessary parts.
Overrides: object.__init__
__call__(self )
Starts the shell
Overrides: igraph.app.shell.Shell.__call__
Inherited from igraph.app.shell.Shell(Section 4.5)
Properties
Name
Inherited from object
__class__
4.7
Description
Class ConsoleProgressBarMixin
object
igraph.app.shell.ConsoleProgressBarMixin
Known Subclasses: igraph.app.shell.ClassicPythonShell, igraph.app.shell.IPythonShell
Mixin class for console shells that support a progress bar.
234
Class IPythonShell
4.7.1
Module igraph.app.shell
Methods
__init__(self )
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: object.__init__ extit(inherited documentation)
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__str__(), __subclasshook__()
4.7.2
Properties
Name
Inherited from object
__class__
4.8
Description
Class IPythonShell
object
igraph.app.shell.Shell
object
igraph.app.shell.ConsoleProgressBarMixin
igraph.app.shell.IPythonShell
IPython embedded shell interface.
This class allows igraph to be embedded in IPythons interactive shell.
235
Class ClassicPythonShell
4.8.1
Module igraph.app.shell
Methods
__init__(self )
Constructor.
Imports IPythons embedded shell with separator lines removed.
Overrides: object.__init__
__call__(self )
Starts the embedded shell.
Overrides: igraph.app.shell.Shell.__call__
Inherited from igraph.app.shell.Shell(Section 4.5)
Properties
Name
Inherited from object
__class__
4.9
Description
Class ClassicPythonShell
object
igraph.app.shell.Shell
object
igraph.app.shell.ConsoleProgressBarMixin
igraph.app.shell.ClassicPythonShell
Classic Python shell interface.
236
Class ClassicPythonShell
Module igraph.app.shell
Methods
__init__(self )
Constructor.
Imports Pythons classic shell
Overrides: object.__init__
__call__(self )
Starts the embedded shell.
Overrides: igraph.app.shell.Shell.__call__
Inherited from igraph.app.shell.Shell(Section 4.5)
Properties
Name
Inherited from object
__class__
Description
237
Module igraph.clustering
Module igraph.clustering
238
Module igraph.clustering
239
Functions
5.1
Module igraph.clustering
Functions
compare_communities(comm1, comm2, method =vi,
remove_none=False)
Compares two community structures using various distance measures.
Parameters
comm1:
comm2:
method:
Functions
Module igraph.clustering
Class Clustering
5.2
Module igraph.clustering
Variables
Name
__package__
5.3
Description
Value: igraph
Class Clustering
object
igraph.clustering.Clustering
Known Subclasses: igraph.clustering.VertexClustering
Class representing a clustering of an arbitrary ordered set.
This is now used as a base for VertexClustering, but it might be useful for other purposes
as well.
Members of an individual cluster can be accessed by the [] operator:
>>>
>>>
cl = Clustering([0,0,0,0,1,1,1,2,2,2,2])
cl[0]
[0, 1, 2, 3]
cl.membership
[0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2]
len(cl)
You can iterate over the clustering object as if it were a regular list of clusters:
>>> for
cluster
in
cl:
...
idx
in
cluster)
...
0 1 2 3
4 5 6
7 8 9 10
If you need all the clusters at once as lists, you can simply convert the clustering object to
a list:
>>>
>>>
cluster_list = list(cl)
print cluster_list
242
Class Clustering
Module igraph.clustering
5.3.1
Methods
Overrides: object.__init__
__getitem__(self, idx )
Returns the members of the specified cluster.
Parameters
idx: the index of the cluster
Return Value
the members of the specified cluster as a list
Raises
IndexError if the index is out of bounds
__iter__(self )
Iterates over the clusters in this clustering.
This method will return a generator that generates the clusters one by one.
__len__(self )
Returns the number of clusters.
Return Value
the number of clusters
__str__(self )
str(x)
Overrides: object.__str__ extit(inherited documentation)
243
Class Clustering
Module igraph.clustering
as_cover(self )
Returns a Cover that contains the same clusters as this clustering.
compare_to(self, other, *args, **kwds)
Compares this clustering to another one using some similarity or distance
metric.
This is a convenience method that simply calls compare_communities with
the two clusterings as arguments. Any extra positional or keyword argument is
also forwarded to compare_communities.
size(self, idx )
Returns the size of a given cluster.
Parameters
idx: the cluster in which we are interested.
sizes(self, *args)
Returns the size of given clusters.
The indices are given as positional arguments. If there are no positional
arguments, the function will return the sizes of all clusters.
size_histogram(self, bin_width=1)
Returns the histogram of cluster sizes.
Parameters
bin_width: the bin width of the histogram
Return Value
a Histogram object
244
Class VertexClustering
Module igraph.clustering
Properties
Name
membership
n
Description
Returns the membership vector.
Returns the number of elements covered by this
clustering.
5.4
Class VertexClustering
object
igraph.clustering.Clustering
igraph.clustering.VertexClustering
Known Subclasses: igraph.cut.Cut
The clustering of the vertex set of a graph.
This class extends Clustering by linking it to a specific Graph object and by optionally
storing the modularity score of the clustering. It also provides some handy methods like
getting the subgraph corresponding to a cluster and such.
245
Class VertexClustering
Module igraph.clustering
Note: since this class is linked to a Graph, destroying the graph by the del operator does not
free the memory occupied by the graph if there exists a VertexClustering that references
the Graph.
5.4.1
Methods
membership:
modularity:
params:
246
Class VertexClustering
Module igraph.clustering
Return Value
a new VertexClustering object
as_cover(self )
Returns a VertexCover that contains the same clusters as this clustering.
Overrides: igraph.clustering.Clustering.as_cover
247
Class VertexClustering
Module igraph.clustering
Return Value
the new graph.
crossing(self )
Returns a boolean vector where element i is True iff edge i lies between
clusters, False otherwise.
recalculate_modularity(self )
Recalculates the stored modularity value.
This method must be called before querying the modularity score of the
clustering through the class member modularity or q if the graph has been
modified (edges have been added or removed) since the creation of the
VertexClustering object.
Return Value
the new modularity score
248
Class VertexClustering
Module igraph.clustering
subgraph(self, idx )
Get the subgraph belonging to a given cluster.
Parameters
idx: the cluster index
Return Value
a copy of the subgraph
Precondition: the vertex set of the graph hasnt been modified since the
moment the clustering was constructed.
subgraphs(self )
Gets all the subgraphs belonging to each of the clusters.
Return Value
a list containing copies of the subgraphs
Precondition: the vertex set of the graph hasnt been modified since the
moment the clustering was constructed.
giant(self )
Returns the giant community of the clustered graph.
The giant component a community for which no larger community exists.
Return Value
a copy of the giant community.
Note: there can be multiple giant communities, this method will return the
copy of an arbitrary one if there are multiple giant communities.
Precondition: the vertex set of the graph hasnt been modified since the
moment the clustering was constructed.
249
Class VertexClustering
Module igraph.clustering
Class Dendrogram
Module igraph.clustering
Properties
Name
Description
modularity
Returns the modularity score
q
Returns the modularity score
graph
Returns the graph belonging to this object
Inherited from igraph.clustering.Clustering (Section 5.3)
membership, n
Inherited from object
__class__
5.5
Class Dendrogram
object
igraph.clustering.Dendrogram
Known Subclasses: igraph.clustering.VertexDendrogram
The hierarchical clustering (dendrogram) of some dataset.
A hierarchical clustering means that we know not only the way the elements are separated
into groups, but also the exact history of how individual elements were joined into larger
subgroups.
This class internally represents the hierarchy by a matrix with n rows and 2 columns or
more precisely, a list of lists of size 2. This is exactly the same as the original format used
by igraphs C core. The ith row of the matrix contains the indices of the two clusters being
joined in time step i. The joint group will be represented by the ID n+i, with i starting
from one. The ID of the joint group will be referenced in the upcoming steps instead of any
of its individual members. So, IDs less than or equal to n (where n is the number of rows
in the matrix) mean the original members of the dataset (with ID from 0 to n), while IDs
up from n+1 mean joint groups. As an example, take a look at the dendrogram and the
internal representation of a given clustering of five nodes:
0 -+
|
1 -+-+
|
2 ---+-+
|
<====>
251
Class Dendrogram
Module igraph.clustering
3 -+
|
|
|
4 -+---+--5.5.1
Methods
__init__(self, merges)
Creates a hierarchical clustering.
Parameters
merges: the merge history either in matrix or tuple format
Overrides: object.__init__
__str__(self )
str(x)
Overrides: object.__str__ extit(inherited documentation)
format(self, format=newick)
Formats the dendrogram in a foreign format.
Currently only the Newick format is supported.
Example:
>>>
>>>
((2,3)4,(0,1)5)6;
>>>
>>>
d.names = list("ABCDEFG")
d.format()
((C,D)E,(A,B)F)G;
252
Class Dendrogram
Module igraph.clustering
Properties
Name
merges
names
Description
Returns the performed merges in matrix format
Returns the names of the nodes in the
dendrogram
continued on next page
253
Class VertexDendrogram
Module igraph.clustering
Name
Inherited from object
__class__
5.6
Description
Class VertexDendrogram
object
igraph.clustering.Dendrogram
igraph.clustering.VertexDendrogram
The dendrogram resulting from the hierarchical clustering of the vertex set of a graph.
5.6.1
Methods
merges:
optimal_count:
params:
Class VertexDendrogram
Module igraph.clustering
as_clustering(self, n=None)
Cuts the dendrogram at the given level and returns a corresponding
VertexClustering object.
Parameters
n: the desired number of clusters. Merges are replayed from the
beginning until the membership vector has exactly n distinct
elements or until there are no more recorded merges, whichever
happens first. If None, the optimal count hint given by the
clustering algorithm will be used If the optimal count was not
given either, it will be calculated by selecting the level where the
modularity is maximal.
Return Value
a new VertexClustering object.
__plot__(self, context, bbox, palette, *args, **kwds)
Draws the vertex dendrogram on the given Cairo context
See Dendrogram.__plot__ for the list of supported keyword arguments.
Overrides: igraph.clustering.Dendrogram.__plot__
Inherited from igraph.clustering.Dendrogram(Section 5.5)
__str__(), format(), summary()
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__subclasshook__()
5.6.2
Properties
Name
optimal_count
Description
Returns the optimal number of clusters for this
dendrogram.
If an optimal count hint was given at
construction time, this property simply returns
the hint. If such a count was not given, this
method calculates the optimal number of
clusters by maximizing the modularity along all
the possible cuts in the dendrogram.
Inherited from igraph.clustering.Dendrogram (Section 5.5)
merges, names
continued on next page
255
Class Cover
Module igraph.clustering
Name
Inherited from object
__class__
5.7
Description
Class Cover
object
igraph.clustering.Cover
Known Subclasses: igraph.clustering.VertexCover
Class representing a cover of an arbitrary ordered set.
Covers are similar to clusterings, but each element of the set may belong to more than one
cluster in a cover, and elements not belonging to any cluster are also allowed.
Cover instances provide a similar API as Clustering instances; for instance, iterating over
a Cover will iterate over the clusters just like with a regular Clustering instance. However,
they are not derived from each other or from a common superclass, and there might be
functions that exist only in one of them or the other.
Clusters of an individual cover can be accessed by the [] operator:
>>>
>>>
[0, 1, 2, 3]
The membership vector can be accessed by the membership property. Note that contrary
to Clustering instances, the membership vector will contain lists that contain the cluster
indices each item belongs to:
>>>
cl.membership
[[0, 2], [0, 2], [0, 1], [0, 1], [1], [], [2]]
len(cl)
You can iterate over the cover as if it were a regular list of clusters:
>>> for
...
cluster
in
cl:
idx
in
cluster)
...
0 1 2 3
2 3 4
256
Class Cover
Module igraph.clustering
0 1 6
If you need all the clusters at once as lists, you can simply convert the cover to a list:
>>>
>>>
cluster_list = list(cl)
print cluster_list
Clustering objects can readily be converted to Cover objects using the constructor:
>>>
>>>
>>>
True
5.7.1
Methods
Overrides: object.__init__
__getitem__(self, index )
Returns the cluster with the given index.
__iter__(self )
Iterates over the clusters in this cover.
__len__(self )
Returns the number of clusters in this cover.
257
Class Cover
Module igraph.clustering
__str__(self )
Returns a string representation of the cover.
Overrides: object.__str__
size(self, idx )
Returns the size of a given cluster.
Parameters
idx: the cluster in which we are interested.
sizes(self, *args)
Returns the size of given clusters.
The indices are given as positional arguments. If there are no positional
arguments, the function will return the sizes of all clusters.
size_histogram(self, bin_width=1)
Returns the histogram of cluster sizes.
Parameters
bin_width: the bin width of the histogram
Return Value
a Histogram object
summary(self, verbosity=0, width=None)
Returns the summary of the cover.
The summary includes the number of items and clusters, and also the list of
members for each of the clusters if the verbosity is nonzero.
Parameters
verbosity: determines whether the cluster members should be
printed. Zero verbosity prints the number of items and
clusters only.
Return Value
the summary of the cover as a string.
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__subclasshook__()
258
Class VertexCover
5.7.2
Module igraph.clustering
Properties
Name
membership
Description
Returns the membership vector of this cover.
The membership vector of a cover covering n
elements is a list of length n, where element i
contains the cluster indices of the ith item.
Returns the number of elements in the set
covered by this cover.
n
Inherited from object
__class__
5.8
Class VertexCover
object
igraph.clustering.Cover
igraph.clustering.VertexCover
Known Subclasses: igraph.clustering.CohesiveBlocks
The cover of the vertex set of a graph.
This class extends Cover by linking it to a specific Graph object. It also provides some handy
methods like getting the subgraph corresponding to a cluster and such.
Note: since this class is linked to a Graph, destroying the graph by the del operator does
not free the memory occupied by the graph if there exists a VertexCover that references the
Graph.
5.8.1
Methods
259
Class VertexCover
Module igraph.clustering
crossing(self )
Returns a boolean vector where element i is True iff edge i lies between
clusters, False otherwise.
subgraph(self, idx )
Get the subgraph belonging to a given cluster.
Parameters
idx: the cluster index
Return Value
a copy of the subgraph
Precondition: the vertex set of the graph hasnt been modified since the
moment the cover was constructed.
subgraphs(self )
Gets all the subgraphs belonging to each of the clusters.
Return Value
a list containing copies of the subgraphs
Precondition: the vertex set of the graph hasnt been modified since the
moment the cover was constructed.
260
Class VertexCover
Module igraph.clustering
Class CohesiveBlocks
Module igraph.clustering
__subclasshook__()
5.8.2
Properties
Name
Description
graph
Returns the graph belonging to this object
Inherited from igraph.clustering.Cover (Section 5.7)
membership, n
Inherited from object
__class__
5.9
Class CohesiveBlocks
object
igraph.clustering.Cover
igraph.clustering.VertexCover
igraph.clustering.CohesiveBlocks
The cohesive block structure of a graph.
Instances of this type are created by Graph.cohesive_blocks(). See the documentation of
Graph.cohesive_blocks() for an explanation of what cohesive blocks are.
This class provides a few more methods that make handling of cohesive block structures
easier.
262
Class CohesiveBlocks
5.9.1
Module igraph.clustering
Methods
cohesion: the cohesion of each block. The length of this list must
be equal to the length of blocks.
parent:
Overrides: object.__init__
See Also: Graph.cohesive_blocks()
cohesion(self, idx )
Returns the cohesion of the group with the given index.
cohesions(self )
Returns the list of cohesion values for each group.
hierarchy(self )
Returns a new graph that describes the hierarchical relationships between the
groups.
The new graph will be a directed tree; an edge will point from vertex i to
vertex j if group i is a superset of group j. In other words, the edges point
downwards.
263
Class CohesiveBlocks
Module igraph.clustering
max_cohesion(self, idx )
Finds the maximum cohesion score among all the groups that contain the
given vertex.
max_cohesions(self )
For each vertex in the graph, returns the maximum cohesion score among all
the groups that contain the vertex.
parent(self, idx )
Returns the parent group index of the group with the given index or None if
the given group is the root.
parents(self )
Returns the list of parent group indices for each group or None if the given
group is the root.
__plot__(self, context, bbox, palette, *args, **kwds)
Plots the cohesive block structure to the given Cairo context in the given
bounding box.
Since a CohesiveBlocks instance is also a VertexCover, keyword arguments
accepted by VertexCover.__plot__() are also accepted here. The only
difference is that the vertices are colored according to their maximal cohesions
by default, and groups are marked by colored blobs except the last group
which encapsulates the whole graph.
See the documentation of VertexCover.__plot__() for more details.
Overrides: igraph.clustering.VertexCover.__plot__
Inherited from igraph.clustering.VertexCover(Section 5.8)
crossing(), subgraph(), subgraphs()
Inherited from igraph.clustering.Cover(Section 5.7)
__getitem__(), __iter__(), __len__(), __str__(), size(), size_histogram(),
sizes(), summary()
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__subclasshook__()
264
Class CohesiveBlocks
5.9.2
Module igraph.clustering
Properties
Name
Description
Inherited from igraph.clustering.VertexCover (Section 5.8)
graph
Inherited from igraph.clustering.Cover (Section 5.7)
membership, n
Inherited from object
__class__
265
Variables
Module igraph.compat
Module igraph.compat
Compatibility methods and backported versions of newer Python features to enable igraph
to run on Python 2.5.
License: Copyright (C) 2006-2012 Tams Nepusz <ntamas@gmail.com> Pzmny Pter
stny 1/a, 1117 Budapest, Hungary
This program is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version
2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program;
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
6.1
Variables
Name
__package__
Description
Value: igraph
266
Module igraph.configuration
Module igraph.configuration
Functions
get_platform_image_viewer()
Returns the path of an image viewer on the given platform
get_user_config_file()
Returns the path where the user-level configuration file is stored
init()
Default mechanism to initiate igraph configuration
This method loads the user-specific configuration file from the users home
directory, or if it does not exist, creates a default configuration.
The method is safe to be called multiple times, it will not parse the
configuration file twice.
Return Value
the Configuration object loaded or created.
267
Class Configuration
7.2
Module igraph.configuration
Variables
Name
__package__
7.3
Description
Value: igraph
Class Configuration
object
igraph.configuration.Configuration
Class representing igraph configuration details.
(section) General ideas
The configuration of igraph is stored in the form of name-value pairs. This object provides
an interface to the configuration data using the syntax known from dict:
>>>
>>>
>>>
c=Configuration()
c["general.verbose"] = True
print c["general.verbose"]
True
Configuration keys are organized into sections, and the name to be used for a given key is
always in the form section.keyname, like general.verbose in the example above. In that
case, general is the name of the configuration section, and verbose is the name of the key.
If the name of the section is omitted, it defaults to general, so general.verbose can be
referred to as verbose:
>>>
>>>
>>>
c=Configuration()
c["verbose"] = True
print c["general.verbose"]
True
Class Configuration
Module igraph.configuration
Class Configuration
Module igraph.configuration
Methods
__init__(self, filename=None)
Creates a new configuration instance.
Parameters
filename: file or file pointer to be read. Can be omitted.
Overrides: object.__init__
__contains__(self, item)
Checks whether the given configuration item is set.
Parameters
item: the configuration key to check.
Return Value
True if the key has an associated value, False otherwise.
__getitem__(self, item)
Returns the given configuration item.
Parameters
item: the configuration key to retrieve.
Return Value
the configuration value
__setitem__(self, item, value)
Sets the given configuration item.
Parameters
item: the configuration key to set
value: the new value of the configuration key
__delitem__(self, item)
Deletes the given item from the configuration.
If the item has a default value, the default value is written back instead of the
current value. Without a default value, the item is really deleted.
270
Class Configuration
Module igraph.configuration
has_key(self, item)
Checks if the configuration has a given key.
Parameters
item: the key being sought
load(self, stream=None)
Loads the configuration from the given file.
Parameters
stream: name of a file or a file object. The configuration will be
loaded from here. Can be omitted, in this case, the
user-level configuration is loaded.
save(self, stream=None)
Saves the configuration.
Parameters
stream: name of a file or a file object. The configuration will be
saved there. Can be omitted, in this case, the user-level
configuration file will be overwritten.
instance(cls)
Returns the single instance of the configuration object.
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__str__(), __subclasshook__()
7.3.2
Properties
Name
filename
Description
Returns the filename associated to the object.
It is usually the name of the configuration file
that was used when creating the object.
Configuration.load always overwrites it with
the filename given to it. If None, the
configuration was either created from scratch or
it was updated from a stream without name
information.
271
Class Configuration
Module igraph.configuration
Name
__class__
Description
272
Class Cut
Module igraph.cut
Module igraph.cut
Variables
Name
__package__
8.2
Description
Value: igraph
Class Cut
object
igraph.clustering.Clustering
igraph.clustering.VertexClustering
igraph.cut.Cut
Known Subclasses: igraph.cut.Flow
A cut of a given graph.
This is a simple class used to represent cuts returned by Graph.mincut(), Graph.all_st_cuts()
and other functions that calculate cuts.
A cut is a special vertex clustering with only two clusters. Besides the usual VertexClustering
methods, it also has the following attributes:
value - the value (capacity) of the cut. It is equal to the number of edges if there are
273
Class Cut
Module igraph.cut
>>> from
>>>
>>>
>>>
2.0
min(map(len, mc))
1
>>>
mc.es["color"] =
"red"
274
Class Cut
8.2.1
Module igraph.cut
Methods
membership:
modularity:
params:
Class Flow
Module igraph.cut
Properties
Name
Description
es
Returns an edge selector restricted to the cut
partition
Returns the vertex IDs partitioned according to
the cut
cut
Returns the edge IDs in the cut
value
Returns the sum of edge capacities in the cut
Inherited from igraph.clustering.VertexClustering (Section 5.4)
graph, modularity, q
Inherited from igraph.clustering.Clustering (Section 5.3)
membership, n
Inherited from object
__class__
8.3
Class Flow
object
igraph.clustering.Clustering
igraph.clustering.VertexClustering
igraph.cut.Cut
igraph.cut.Flow
A flow of a given graph.
This is a simple class used to represent flows returned by Graph.maxflow. It has the following
attributes:
graph - the graph on which this flow is defined
value - the value (capacity) of the flow
276
Class Flow
Module igraph.cut
flow - the flow values on each edge. For directed graphs, this is simply a list where
element i corresponds to the flow on edge i. For undirected graphs, the direction of
the flow is not constrained (since the edges are undirected), hence positive flow always
means a flow from the smaller vertex ID to the larger, while negative flow means a flow
from the larger vertex ID to the smaller.
cut - edge IDs in the minimal cut corresponding to the flow.
partition - vertex IDs in the parts created after removing edges in the cut
es - an edge selector restricted to the edges in the cut.
This class is usually not instantiated directly, everything is taken care of by Graph.maxflow.
Examples:
igraph import Graph
g = Graph.Ring(20)
mf = g.maxflow(0, 10)
print mf.value
>>> from
>>>
>>>
>>>
2.0
>>>
mf.es["color"] =
"red"
277
Class Flow
8.3.1
Module igraph.cut
Methods
membership:
modularity:
params:
Class Flow
Module igraph.cut
Properties
Name
Description
flow
Returns the flow values for each edge.
For directed graphs, this is simply a list where
element i corresponds to the flow on edge i. For
undirected graphs, the direction of the flow is
not constrained (since the edges are
undirected), hence positive flow always means a
flow from the smaller vertex ID to the larger,
while negative flow means a flow from the
larger vertex ID to the smaller.
Inherited from igraph.cut.Cut (Section 8.2)
cut, es, partition, value
Inherited from igraph.clustering.VertexClustering (Section 5.4)
graph, modularity, q
Inherited from igraph.clustering.Clustering (Section 5.3)
membership, n
Inherited from object
__class__
279
Class Matrix
Module igraph.datatypes
Module igraph.datatypes
Variables
Name
__package__
9.2
Description
Value: igraph
Class Matrix
object
igraph.datatypes.Matrix
Simple matrix data type.
Of course there are much more advanced matrix data types for Python (for instance, the
ndarray data type of Numeric Python) and this implementation does not want to compete
with them. The only role of this data type is to provide a convenient interface for the
matrices returned by the Graph object (for instance, allow indexing with tuples in the case
of adjacency matrices and so on).
280
Class Matrix
9.2.1
Module igraph.datatypes
Methods
__init__(self, data=None)
Initializes a matrix.
Parameters
data: the elements of the matrix as a list of lists, or None to create
a 0x0 matrix.
Overrides: object.__init__
Fill(cls, value, *args)
Creates a matrix filled with the given value
Parameters
value: the value to be used
shape: the shape of the matrix. Can be a single integer, two
integers or a tuple. If a single integer is given here, the
matrix is assumed to be square-shaped.
Zero(cls, *args)
Creates a matrix filled with zeros.
Parameters
shape: the shape of the matrix. Can be a single integer, two
integers or a tuple. If a single integer is given here, the
matrix is assumed to be square-shaped.
Identity(cls, *args)
Creates an identity matrix.
Parameters
shape: the shape of the matrix. Can be a single integer, two
integers or a tuple. If a single integer is given here, the
matrix is assumed to be square-shaped.
281
Class Matrix
Module igraph.datatypes
__add__(self, other )
Adds the given value to the matrix.
Parameters
other: either a scalar or a matrix. Scalars will be added to each
element of the matrix. Matrices will be added together
elementwise.
Return Value
the result matrix
__eq__(self, other )
Checks whether a given matrix is equal to another one
__getitem__(self, i)
Returns a single item, a row or a column of the matrix
Parameters
i: if a single integer, returns the ith row as a list. If a slice, returns
the corresponding rows as another Matrix object. If a 2-tuple,
the first element of the tuple is used to select a row and the
second is used to select a column.
__hash__(self )
Returns a hash value for a matrix.
Overrides: object.__hash__
__iadd__(self, other )
In-place addition of a matrix or scalar.
__isub__(self, other )
In-place subtraction of a matrix or scalar.
__ne__(self, other )
Checks whether a given matrix is not equal to another one
282
Class Matrix
Module igraph.datatypes
__setitem__(self, i, value)
Sets a single item, a row or a column of the matrix
Parameters
i:
if a single integer, sets the ith row as a list. If a slice, sets
the corresponding rows from another Matrix object. If a
2-tuple, the first element of the tuple is used to select a row
and the second is used to select a column.
value: the new value
__sub__(self, other )
Subtracts the given value from the matrix.
Parameters
other: either a scalar or a matrix. Scalars will be subtracted from
each element of the matrix. Matrices will be subtracted
together elementwise.
Return Value
the result matrix
__repr__(self )
repr(x)
Overrides: object.__repr__ extit(inherited documentation)
__str__(self )
str(x)
Overrides: object.__str__ extit(inherited documentation)
__iter__(self )
Support for iteration.
This is actually implemented as a generator, so there is no need for a separate
iterator class. The generator returns copies of the rows in the matrix as lists
to avoid messing around with the internals. Feel free to do anything with the
copies, the changes wont be reflected in the original matrix.
283
Class Matrix
Module igraph.datatypes
284
Class DyadCensus
Module igraph.datatypes
min(self, dim=None)
Returns the minimum of the matrix along the given dimension
Parameters
dim: the dimension. 0 means determining the column minimums, 1
means determining the row minimums. If None, the global
minimum is returned.
max(self, dim=None)
Returns the maximum of the matrix along the given dimension
Parameters
dim: the dimension. 0 means determining the column maximums, 1
means determining the row maximums. If None, the global
maximum is returned.
Inherited from object
__delattr__(), __format__(), __getattribute__(), __new__(), __reduce__(),
__reduce_ex__(), __setattr__(), __sizeof__(), __subclasshook__()
9.2.2
Properties
Name
data
shape
Inherited from object
__class__
9.3
Description
Returns the data stored in the matrix as a list
of lists
Returns the shape of the matrix as a tuple
Class DyadCensus
object
tuple
igraph.datatypes.DyadCensus
Dyad census of a graph.
This is a pretty simple class - basically it is a tuple, but it allows the user to refer to its
individual items by the names mutual (or mut), asymmetric (or asy or asym or asymm) and
null.
285
Class DyadCensus
Module igraph.datatypes
Examples:
igraph import Graph
g=Graph.Erdos_Renyi(100, 0.2, directed=True)
dc=g.dyad_census()
print dc.mutual
#doctest:+SKIP
>>> from
>>>
>>>
>>>
179
dc["asym"]
#doctest:+SKIP
1609
>>> print
tuple(dc), list(dc)
#doctest:+SKIP
sorted(dc.as_dict().items())
#doctest:+ELLIPSIS
9.3.1
Methods
__getitem__(self, idx )
x[y]
Overrides: tuple.__getitem__ extit(inherited documentation)
__getattr__(self, attr )
__repr__(self )
repr(x)
Overrides: object.__repr__ extit(inherited documentation)
__str__(self )
str(x)
Overrides: object.__str__ extit(inherited documentation)
as_dict(self )
Converts the dyad census to a dict using the known dyad names.
Inherited from tuple
__add__(), __contains__(), __eq__(), __ge__(), __getattribute__(), __getnewargs__(), __getslice__(), __gt__(), __hash__(), __iter__(), __le__(),
__len__(), __lt__(), __mul__(), __ne__(), __new__(), __rmul__(),
__sizeof__(), count(), index()
286
Class TriadCensus
Module igraph.datatypes
Properties
Name
Inherited from object
__class__
9.4
Description
Class TriadCensus
object
tuple
igraph.datatypes.TriadCensus
Triad census of a graph.
This is a pretty simple class - basically it is a tuple, but it allows the user to refer to its
individual items by the following triad names:
Class TriadCensus
Module igraph.datatypes
Attribute and item accessors are provided. Due to the syntax of Python, attribute names
are not allowed to start with a number, therefore the triad names must be prepended with a
lowercase t when accessing them as attributes. This is not necessary with the item accessor
syntax.
Examples:
igraph import Graph
g=Graph.Erdos_Renyi(100, 0.2, directed=True)
tc=g.triad_census()
print tc.t003
#doctest:+SKIP
>>> from
>>>
>>>
>>>
39864
>>> print
tc["030C"]
#doctest:+SKIP
1206
9.4.1
Methods
__getitem__(self, idx )
x[y]
Overrides: tuple.__getitem__ extit(inherited documentation)
__getattr__(self, attr )
__repr__(self )
repr(x)
Overrides: object.__repr__ extit(inherited documentation)
__str__(self )
str(x)
Overrides: object.__str__ extit(inherited documentation)
Inherited from tuple
__add__(), __contains__(), __eq__(), __ge__(), __getattribute__(), __getnewargs__(), __getslice__(), __gt__(), __hash__(), __iter__(), __le__(),
__len__(), __lt__(), __mul__(), __ne__(), __new__(), __rmul__(),
__sizeof__(), count(), index()
Inherited from object
__delattr__(), __format__(), __init__(), __reduce__(), __reduce_ex__(),
288
Class UniqueIdGenerator
Module igraph.datatypes
__setattr__(), __subclasshook__()
9.4.2
Properties
Name
Inherited from object
__class__
9.5
Description
Class UniqueIdGenerator
object
igraph.datatypes.UniqueIdGenerator
A dictionary-like class that can be used to assign unique IDs to names (say, vertex names).
Usage:
>>>
>>>
gen = UniqueIdGenerator()
gen["A"]
0
>>>
gen["B"]
1
>>>
gen["C"]
2
>>>
gen["A"]
gen.add("D")
# Synonym of gen["D"]
0
>>>
3
>>>
len(gen)
4
>>> "C" in
gen
True
>>> "E" in
gen
False
289
Class UniqueIdGenerator
9.5.1
Module igraph.datatypes
Methods
290
Class UniqueIdGenerator
Module igraph.datatypes
Properties
Name
Inherited from object
__class__
Description
291
Package igraph.drawing
10
Package igraph.drawing
Modules
292
Modules
Package igraph.drawing
293
Functions
10.2
Package igraph.drawing
Functions
plot(obj, target=None, bbox =(0, 0, 600, 600), *args, **kwds)
Plots the given object to the given target.
Positional and keyword arguments not explicitly mentioned here will be passed
down to the __plot__ method of the object being plotted. Since you are most
likely interested in the keyword arguments available for graph plots, see
Graph.__plot__ as well.
Parameters
obj:
Class DefaultGraphDrawer
10.3
Package igraph.drawing
Class DefaultGraphDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.graph.AbstractGraphDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.baseclasses.AbstractCairoDrawer
igraph.drawing.graph.AbstractCairoGraphDrawer
igraph.drawing.graph.DefaultGraphDrawer
Class implementing the default visualisation of a graph.
The default visualisation of a graph draws the nodes on a 2D plane according to a given
Layout, then draws a straight or curved edge between nodes connected by edges. This is
the visualisation used when one invokes the plot() function on a Graph object.
See Graph.__plot__() for the keyword arguments understood by this drawer.
295
Class DefaultGraphDrawer
10.3.1
Package igraph.drawing
Methods
296
Class BoundingBox
Package igraph.drawing
Properties
Name
Description
Inherited from igraph.drawing.baseclasses.AbstractCairoDrawer (Section 11.3)
bbox
Inherited from object
__class__
10.4
Class BoundingBox
object
igraph.drawing.utils.Rectangle
igraph.drawing.utils.BoundingBox
Class representing a bounding box (a rectangular area) that encloses some objects.
297
Class BoundingBox
10.4.1
Package igraph.drawing
Methods
__ior__(self, other )
Replaces this bounding box with the union of itself and another.
Example:
>>> box1 = BoundingBox(10, 20, 50, 60)
>>> box2 = BoundingBox(70, 40, 100, 90)
>>> box1 |= box2
>>> print(box1)
BoundingBox(10.0, 20.0, 100.0, 90.0)
Overrides: igraph.drawing.utils.Rectangle.__ior__
__or__(self, other )
Takes the union of this bounding box with another.
The result is a bounding box which encloses both bounding boxes.
Example:
>>> box1 = BoundingBox(10, 20, 50, 60)
>>> box2 = BoundingBox(70, 40, 100, 90)
>>> box1 | box2
BoundingBox(10.0, 20.0, 100.0, 90.0)
Overrides: igraph.drawing.utils.Rectangle.__or__
Inherited from igraph.drawing.utils.Rectangle(Section 19.1)
__and__(), __bool__(), __eq__(), __hash__(), __init__(), __ne__(),
__nonzero__(), __repr__(), contract(), expand(), intersection(), isdisjoint(),
isempty(), translate(), union()
Inherited from object
__delattr__(), __format__(), __getattribute__(), __new__(), __reduce__(),
__reduce_ex__(), __setattr__(), __sizeof__(), __str__(), __subclasshook__()
10.4.2
Properties
Name
Description
Inherited from igraph.drawing.utils.Rectangle (Section 19.1)
bottom, coords, height, left, midx, midy, right, shape, top, width
Inherited from object
continued on next page
298
Class Point
Package igraph.drawing
Name
__class__
10.5
Description
Class Point
object
tuple
igraph.drawing.utils.Point
Class representing a point on the 2D plane.
10.5.1
Methods
__new__(cls, x, y)
Creates a new point with the given coordinates
Return Value
a new object with type S, a subtype of T
Overrides: object.__new__
__repr__(self )
Returns a nicely formatted representation of the point
Overrides: object.__repr__
__getnewargs__(self )
Return self as a plain tuple. Used by copy and pickle.
Overrides: tuple.__getnewargs__
__add__(self, other )
Adds the coordinates of a point to another one
Overrides: tuple.__add__
__sub__(self, other )
Subtracts the coordinates of a point to another one
299
Class Point
Package igraph.drawing
__mul__(self, scalar )
Multiplies the coordinates by a scalar
Overrides: tuple.__mul__
__rmul__(self, scalar )
Multiplies the coordinates by a scalar
Overrides: tuple.__rmul__
__div__(self, scalar )
Divides the coordinates by a scalar
as_polar(self )
Returns the polar coordinate representation of the point.
Return Value
the radius and the angle in a tuple.
distance(self, other )
Returns the distance of the point from another one.
Example:
>>>
>>>
>>>
p1 = Point(5, 7)
p2 = Point(8, 3)
p1.distance(p2)
5.0
300
Class Rectangle
Package igraph.drawing
normalized(self )
Normalizes the coordinates of the point s.t. its length will be 1 after
normalization. Returns the normalized point.
sq_length(self )
Returns the squared length of the vector pointing from the origin to this point.
towards(self, other, distance=0)
Returns the point that is at a given distance from this point towards another
one.
FromPolar(cls, radius, angle)
Constructs a point from polar coordinates.
radius is the distance of the point from the origin; angle is the angle
between the X axis and the vector pointing to the point from the origin.
Inherited from tuple
__contains__(), __eq__(), __ge__(), __getattribute__(), __getitem__(),
__getslice__(), __gt__(), __hash__(), __iter__(), __le__(), __len__(),
__lt__(), __ne__(), __sizeof__(), count(), index()
Inherited from object
__delattr__(), __format__(), __init__(), __reduce__(), __reduce_ex__(),
__setattr__(), __str__(), __subclasshook__()
10.5.2
Properties
Name
x
y
Inherited from object
__class__
10.6
Description
Alias for field number 0
Alias for field number 1
Class Rectangle
object
igraph.drawing.utils.Rectangle
301
Class Rectangle
Package igraph.drawing
Methods
__init__(self, *args)
Creates a rectangle.
The corners of the rectangle can be specified by either a tuple (four items, two
for each corner, respectively), four separate numbers (X and Y coordinates for
each corner) or two separate numbers (width and height, the upper left corner
is assumed to be at (0,0))
Overrides: object.__init__
contract(self, margins)
Contracts the rectangle by the given margins.
Return Value
a new Rectangle object.
expand(self, margins)
Expands the rectangle by the given margins.
Return Value
a new Rectangle object.
isdisjoint(self, other )
Returns True if the two rectangles have no intersection.
Example:
>>> r1 = Rectangle(10, 10, 30, 30)
>>> r2 = Rectangle(20, 20, 50, 50)
>>> r3 = Rectangle(70, 70, 90, 90)
>>> r1.isdisjoint(r2)
False
>>> r2.isdisjoint(r1)
False
>>> r1.isdisjoint(r3)
True
>>> r3.isdisjoint(r1)
True
302
Class Rectangle
Package igraph.drawing
isempty(self )
Returns True if the rectangle is empty (i.e. it has zero width and height).
Example:
>>> r1 = Rectangle(10, 10, 30, 30)
>>> r2 = Rectangle(70, 70, 90, 90)
>>> r1.isempty()
False
>>> r2.isempty()
False
>>> r1.intersection(r2).isempty()
True
intersection(self, other )
Returns the intersection of this rectangle with another.
Example:
>>> r1 = Rectangle(10, 10, 30, 30)
>>> r2 = Rectangle(20, 20, 50, 50)
>>> r3 = Rectangle(70, 70, 90, 90)
>>> r1.intersection(r2)
Rectangle(20.0, 20.0, 30.0, 30.0)
>>> r2 & r1
Rectangle(20.0, 20.0, 30.0, 30.0)
>>> r2.intersection(r1) == r1.intersection(r2)
True
>>> r1.intersection(r3)
Rectangle(0.0, 0.0, 0.0, 0.0)
303
Class Rectangle
Package igraph.drawing
__and__(self, other )
Returns the intersection of this rectangle with another.
Example:
>>> r1 = Rectangle(10, 10, 30, 30)
>>> r2 = Rectangle(20, 20, 50, 50)
>>> r3 = Rectangle(70, 70, 90, 90)
>>> r1.intersection(r2)
Rectangle(20.0, 20.0, 30.0, 30.0)
>>> r2 & r1
Rectangle(20.0, 20.0, 30.0, 30.0)
>>> r2.intersection(r1) == r1.intersection(r2)
True
>>> r1.intersection(r3)
Rectangle(0.0, 0.0, 0.0, 0.0)
translate(self, dx, dy)
Translates the rectangle in-place.
Example:
>>>
>>>
>>>
Parameters
dx: the X coordinate of the translation vector
dy: the Y coordinate of the translation vector
304
Class Rectangle
Package igraph.drawing
union(self, other )
Returns the union of this rectangle with another.
The resulting rectangle is the smallest rectangle that contains both rectangles.
Example:
>>> r1 = Rectangle(10, 10, 30, 30)
>>> r2 = Rectangle(20, 20, 50, 50)
>>> r3 = Rectangle(70, 70, 90, 90)
>>> r1.union(r2)
Rectangle(10.0, 10.0, 50.0, 50.0)
>>> r2 | r1
Rectangle(10.0, 10.0, 50.0, 50.0)
>>> r2.union(r1) == r1.union(r2)
True
>>> r1.union(r3)
Rectangle(10.0, 10.0, 90.0, 90.0)
__or__(self, other )
Returns the union of this rectangle with another.
The resulting rectangle is the smallest rectangle that contains both rectangles.
Example:
>>> r1 = Rectangle(10, 10, 30, 30)
>>> r2 = Rectangle(20, 20, 50, 50)
>>> r3 = Rectangle(70, 70, 90, 90)
>>> r1.union(r2)
Rectangle(10.0, 10.0, 50.0, 50.0)
>>> r2 | r1
Rectangle(10.0, 10.0, 50.0, 50.0)
>>> r2.union(r1) == r1.union(r2)
True
>>> r1.union(r3)
Rectangle(10.0, 10.0, 90.0, 90.0)
305
Class Rectangle
Package igraph.drawing
__ior__(self, other )
Expands this rectangle to include itself and another completely while still
being as small as possible.
Example:
>>> r1 = Rectangle(10, 10, 30, 30)
>>> r2 = Rectangle(20, 20, 50, 50)
>>> r3 = Rectangle(70, 70, 90, 90)
>>> r1 |= r2
>>> r1
Rectangle(10.0, 10.0, 50.0, 50.0)
>>> r1 |= r3
>>> r1
Rectangle(10.0, 10.0, 90.0, 90.0)
__repr__(self )
repr(x)
Overrides: object.__repr__ extit(inherited documentation)
__eq__(self, other )
__ne__(self, other )
__bool__(self )
__nonzero__(self )
__hash__(self )
hash(x)
Overrides: object.__hash__ extit(inherited documentation)
Inherited from object
__delattr__(), __format__(), __getattribute__(), __new__(), __reduce__(),
__reduce_ex__(), __setattr__(), __sizeof__(), __str__(), __subclasshook__()
10.6.2
Properties
306
Class Plot
Package igraph.drawing
Name
coords
width
height
left
right
top
bottom
midx
midy
shape
Inherited from object
__class__
10.7
Description
The coordinates of the corners.
The coordinates are returned as a 4-tuple in the
following order: left edge, top edge, right edge,
bottom edge.
The width of the rectangle
The height of the rectangle
The X coordinate of the left side of the box
The X coordinate of the right side of the box
The Y coordinate of the top edge of the box
The Y coordinate of the bottom edge of the box
The X coordinate of the center of the box
The Y coordinate of the center of the box
The shape of the rectangle (width, height)
Class Plot
object
igraph.drawing.Plot
Class representing an arbitrary plot
Every plot has an associated surface object where the plotting is done. The surface is an
instance of cairo.Surface, a member of the pycairo library. The surface itself provides a
unified API to various plotting targets like SVG files, X11 windows, PostScript files, PNG
files and so on. igraph usually does not know on which surface it is plotting right now, since
pycairo takes care of the actual drawing. Everything thats supported by pycairo should
be supported by this class as well.
Current Cairo surfaces that Im aware of are:
If you create a Plot object with a string given as the target surface, the string will be treated
as a filename, and its extension will decide which surface class will be used. Please note that
307
Class Plot
Package igraph.drawing
308
Class Plot
10.7.1
Package igraph.drawing
Methods
bbox:
palette:
309
Class Plot
Package igraph.drawing
palette: the color palette used for drawing the object. If the object
tries to get a color assigned to a positive integer, it will
use this palette. If None, defaults to the global palette of
the plot.
opacity: the opacity of the object being plotted, in the range
0.0-1.0
See Also: Graph.__plot__
remove(self, obj, bbox =None, idx =1)
Removes an object from the plot.
If the object has been added multiple times and no bounding box was
specified, it removes the instance which occurs idx th in the list of identical
instances of the object.
Parameters
obj: the object to be removed
bbox: optional bounding box specification for the object. If given,
only objects with exactly this bounding box will be
considered.
idx: if multiple objects match the specification given by obj and
bbox, only the idx th occurrence will be removed.
Return Value
True if the object has been removed successfully, False if the object
was not on the plot at all or idx was larger than the count of
occurrences
mark_dirty(self )
Marks the plot as dirty (should be redrawn)
310
Class Plot
Package igraph.drawing
redraw(self, context=None)
Redraws the plot
save(self, fname=None)
Saves the plot.
Parameters
fname: the filename to save to. It is ignored if the surface of the plot
is not an ImageSurface.
show(self )
Saves the plot to a temporary file and shows it.
_repr_svg_(self )
Returns an SVG representation of this plot as a string.
This method is used by IPython to display this plot inline.
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__str__(), __subclasshook__()
10.7.2
Properties
Name
background
bounding_box
height
surface
width
Description
Returns the background color of the plot. None
means a transparent background.
Returns the bounding box of the Cairo surface
as a BoundingBox object
Returns the height of the Cairo surface on
which the plot is drawn
Returns the Cairo surface on which the plot is
drawn
Returns the width of the Cairo surface on
which the plot is drawn
311
Class AbstractDrawer
11
Module igraph.drawing.baseclasses
Module igraph.drawing.baseclasses
Variables
Name
__package__
11.2
Description
Value: igraph.drawing
Class AbstractDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
Methods
Properties
Name
Inherited from object
__class__
Description
312
Class AbstractCairoDrawer
11.3
Module igraph.drawing.baseclasses
Class AbstractCairoDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.baseclasses.AbstractCairoDrawer
Methods
Overrides: object.__init__
draw(self, *args, **kwds)
Abstract method, must be implemented in derived classes.
Overrides: igraph.drawing.baseclasses.AbstractDrawer.draw
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__str__(), __subclasshook__()
11.3.2
Properties
313
Class AbstractXMLRPCDrawer
Name
bbox
Module igraph.drawing.baseclasses
Description
The bounding box of the drawing area where
this drawer will draw.
11.4
Class AbstractXMLRPCDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.baseclasses.AbstractXMLRPCDrawe
Methods
the URL where the XML-RPC calls for the service should
be addressed to.
Class AbstractXMLRPCDrawer
11.4.2
Module igraph.drawing.baseclasses
Properties
Name
Inherited from object
__class__
Description
315
Module igraph.drawing.colors
12
Module igraph.drawing.colors
Functions
color_name_to_rgb(color, palette=None)
Converts a color given in one of the supported color formats to R-G-B values.
This is done by calling color_name_to_rgba and then throwing away the
alpha value.
See Also: color_name_to_rgba for more details about what formats are
understood by this function.
316
Functions
Module igraph.drawing.colors
color_name_to_rgba(color, palette=None)
Converts a color given in one of the supported color formats to R-G-B-A
values.
Examples:
>>>
color_name_to_rgba("red")
True
>>>
True
>>>
True
>>>
color_name_to_rgba("rgb(100%,
50%, 0%)")
color_name_to_rgba("rgba(100%,
color_name_to_rgba("hsla(120,
color_name_to_rgba("hsl(60,
100%, 50%)")
color_name_to_rgba("hsv(60,
100%, 100%)")
Parameters
color:
Functions
Module igraph.drawing.colors
hsla_to_rgba(h, s, l, alpha=1.0)
Converts a color given by its HSLA coordinates (hue, saturation, lightness,
alpha) to RGBA coordinates.
Each of the HSLA coordinates must be in the range [0, 1].
hsl_to_rgb(h, s, l )
Converts a color given by its HSL coordinates (hue, saturation, lightness) to
RGB coordinates.
Each of the HSL coordinates must be in the range [0, 1].
hsva_to_rgba(h, s, v, alpha=1.0)
Converts a color given by its HSVA coordinates (hue, saturation, value, alpha)
to RGB coordinates.
Each of the HSVA coordinates must be in the range [0, 1].
hsv_to_rgb(h, s, v )
Converts a color given by its HSV coordinates (hue, saturation, value) to RGB
coordinates.
Each of the HSV coordinates must be in the range [0, 1].
rgba_to_hsla(r, g, b, alpha=1.0)
Converts a color given by its RGBA coordinates to HSLA coordinates (hue,
saturation, lightness, alpha).
Each of the RGBA coordinates must be in the range [0, 1].
rgba_to_hsva(r, g, b, alpha=1.0)
Converts a color given by its RGBA coordinates to HSVA coordinates (hue,
saturation, value, alpha).
Each of the RGBA coordinates must be in the range [0, 1].
rgb_to_hsl(r, g, b)
Converts a color given by its RGB coordinates to HSL coordinates (hue,
saturation, lightness).
Each of the RGB coordinates must be in the range [0, 1].
318
Class Palette
Module igraph.drawing.colors
rgb_to_hsv(r, g, b)
Converts a color given by its RGB coordinates to HSV coordinates (hue,
saturation, value).
Each of the RGB coordinates must be in the range [0, 1].
12.2
Variables
Name
known_colors
palettes
12.3
Description
Value: {alice blue: (0.941176470588,
0.972549019608, 1.0, 1.0)...
Value: {gray: <GradientPalette with
256 colors>, heat: <Adva...
Class Palette
object
igraph.drawing.colors.Palette
Methods
__init__(self, n)
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: object.__init__ extit(inherited documentation)
319
Class Palette
Module igraph.drawing.colors
clear_cache(self )
Clears the result cache.
The return values of Palette.get are cached. Use this method to clear the
cache.
get(self, v )
Returns the given color from the palette.
Values are cached: if the specific value given has already been looked up, its
value will be returned from the cache instead of calculating it again. Use
Palette.clear_cache to clear the cache if necessary.
Parameters
v: the color to be retrieved. If it is an integer, it is passed to
Palette._get to be translated to an RGBA quadruplet.
Otherwise it is passed to color_name_to_rgb() to determine the
RGBA values.
Return Value
the color as an RGBA quadruplet
Note: you shouldnt override this method in subclasses, override _get instead.
If you override this method, lookups in the known_colors dict wont work, so
you wont be able to refer to colors by names or RGBA quadruplets, only by
integer indices. The caching functionality will disappear as well. However, feel
free to override this method if this is exactly the behaviour you want.
get_many(self, colors)
Returns multiple colors from the palette.
Values are cached: if the specific value given has already been looked upon, its
value will be returned from the cache instead of calculating it again. Use
Palette.clear_cache to clear the cache if necessary.
Parameters
colors: the list of colors to be retrieved. The palette class tries to
make an educated guess here: if it is not possible to
interpret the value you passed here as a list of colors, the
class will simply try to interpret it as a single color by
forwarding the value to Palette.get.
Return Value
the colors as a list of RGBA quadruplets. The result will be a list
even if you passed a single color index or color name.
320
Class Palette
Module igraph.drawing.colors
__getitem__(self, v )
Returns the given color from the palette.
Values are cached: if the specific value given has already been looked up, its
value will be returned from the cache instead of calculating it again. Use
Palette.clear_cache to clear the cache if necessary.
Parameters
v: the color to be retrieved. If it is an integer, it is passed to
Palette._get to be translated to an RGBA quadruplet.
Otherwise it is passed to color_name_to_rgb() to determine the
RGBA values.
Return Value
the color as an RGBA quadruplet
Note: you shouldnt override this method in subclasses, override _get instead.
If you override this method, lookups in the known_colors dict wont work, so
you wont be able to refer to colors by names or RGBA quadruplets, only by
integer indices. The caching functionality will disappear as well. However, feel
free to override this method if this is exactly the behaviour you want.
__len__(self )
Returns the number of colors in this palette
__plot__(self, context, bbox, palette, *args, **kwds)
Plots the colors of the palette on the given Cairo context
Supported keyword arguments are:
border_width: line width of the border shown around the palette. If zero
or negative, the border is turned off. Default is 1.
grid_width: line width of the grid that separates palette cells. If zero or
negative, the grid is turned off. The grid is also turned off if the size of a
cell is less than three times the given line width. Default is 0. Fractional
widths are also allowed.
orientation: the orientation of the palette. Must be one of the following
values: left-right, bottom-top, right-left or top-bottom. Possible
aliases: horizontal = left-right, vertical = bottom-top, lr =
left-right, rl = right-left, tb = top-bottom, bt = bottom-top.
The default is left-right.
321
Class GradientPalette
Module igraph.drawing.colors
__repr__(self )
repr(x)
Overrides: object.__repr__ extit(inherited documentation)
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __setattr__(), __sizeof__(), __str__(),
__subclasshook__()
12.3.2
Properties
Name
Description
Returns the number of colors in this palette
length
Inherited from object
__class__
12.4
Class GradientPalette
object
igraph.drawing.colors.Palette
igraph.drawing.colors.GradientPalette
Base class for gradient palettes
Gradient palettes contain a gradient between two given colors.
Example:
>>>
>>>
pal = GradientPalette("red",
pal.get(0)
"blue",
5)
pal.get(2)
pal.get(4)
322
Class AdvancedGradientPalette
12.4.1
Module igraph.drawing.colors
Methods
Overrides: object.__init__
Inherited from igraph.drawing.colors.Palette(Section 12.3)
__getitem__(), __len__(), __plot__(), __repr__(), clear_cache(), get(),
get_many()
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __setattr__(), __sizeof__(), __str__(),
__subclasshook__()
12.4.2
Properties
Name
Description
Inherited from igraph.drawing.colors.Palette (Section 12.3)
length
Inherited from object
__class__
12.5
Class AdvancedGradientPalette
object
igraph.drawing.colors.Palette
igraph.drawing.colors.AdvancedGradientPalette
Advanced gradient that consists of more than two base colors.
Example:
>>>
pal = AdvancedGradientPalette(["red",
323
"black", "blue"],
n=9)
Class AdvancedGradientPalette
>>>
Module igraph.drawing.colors
pal.get(2)
pal.get(7)
12.5.1
Methods
Overrides: object.__init__
Inherited from igraph.drawing.colors.Palette(Section 12.3)
__getitem__(), __len__(), __plot__(), __repr__(), clear_cache(), get(),
get_many()
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __setattr__(), __sizeof__(), __str__(),
__subclasshook__()
12.5.2
Properties
Name
Description
Inherited from igraph.drawing.colors.Palette (Section 12.3)
length
Inherited from object
__class__
324
Class RainbowPalette
12.6
Module igraph.drawing.colors
Class RainbowPalette
object
igraph.drawing.colors.Palette
igraph.drawing.colors.RainbowPalette
A palette that varies the hue of the colors along a scale.
Colors in a rainbow palette all have the same saturation, value and alpha components, while
the hue is varied between two given extremes linearly. This palette has the advantage that
it wraps around nicely if the hue is varied between zero and one (which is the default).
Example:
>>>
>>>
pal = RainbowPalette(n=120)
pal.get(0)
pal.get(20)
pal.get(40)
pal.get(80)
pal.get(100)
pal = RainbowPalette(n=120)
pal2 = RainbowPalette(n=120, start=0.5, end=0.5)
pal.get(60) == pal2.get(0)
True
>>>
pal.get(90) == pal2.get(30)
True
325
Class PrecalculatedPalette
12.6.1
Module igraph.drawing.colors
Methods
v:
start: the hue at which the rainbow begins (between 0 and 1).
end:
Properties
Name
Description
Inherited from igraph.drawing.colors.Palette (Section 12.3)
length
Inherited from object
__class__
12.7
Class PrecalculatedPalette
object
igraph.drawing.colors.Palette
igraph.drawing.colors.PrecalculatedPalette
326
Class ClusterColoringPalette
Module igraph.drawing.colors
Methods
__init__(self, l )
Creates the palette backed by the given list. The list must contain RGBA
quadruplets or color names, which will be resolved first by
color_name_to_rgba(). Anything that is understood by
color_name_to_rgba() is OK here.
Overrides: object.__init__
Inherited from igraph.drawing.colors.Palette(Section 12.3)
__getitem__(), __len__(), __plot__(), __repr__(), clear_cache(), get(),
get_many()
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __setattr__(), __sizeof__(), __str__(),
__subclasshook__()
12.7.2
Properties
Name
Description
Inherited from igraph.drawing.colors.Palette (Section 12.3)
length
Inherited from object
__class__
12.8
Class ClusterColoringPalette
object
igraph.drawing.colors.Palette
igraph.drawing.colors.PrecalculatedPalette
igraph.drawing.colors.ClusterColoringPalette
327
Class ClusterColoringPalette
Module igraph.drawing.colors
Methods
__init__(self, n)
Creates the palette backed by the given list. The list must contain RGBA
quadruplets or color names, which will be resolved first by
color_name_to_rgba(). Anything that is understood by
color_name_to_rgba() is OK here.
Overrides: object.__init__ extit(inherited documentation)
Inherited from igraph.drawing.colors.Palette(Section 12.3)
__getitem__(), __len__(), __plot__(), __repr__(), clear_cache(), get(),
get_many()
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __setattr__(), __sizeof__(), __str__(),
__subclasshook__()
12.8.2
Properties
Name
Description
Inherited from igraph.drawing.colors.Palette (Section 12.3)
length
Inherited from object
__class__
328
Class CoordinateSystem
13
Module igraph.drawing.coord
Module igraph.drawing.coord
Variables
Name
__package__
13.2
Description
Value: igraph.drawing
Class CoordinateSystem
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.baseclasses.AbstractCairoDrawer
igraph.drawing.coord.CoordinateSystem
Known Subclasses: igraph.drawing.coord.DescartesCoordinateSystem
Class implementing a coordinate system object.
Coordinate system objects are used when drawing plots which 2D or 3D coordinate system
axes. This is an abstract class which must be extended in order to use it. In general, youll
only need the documentation of this class if you intend to implement an own coordinate
system not present in igraph yet.
13.2.1
Methods
Overrides: object.__init__
329
Class DescartesCoordinateSystem
Module igraph.drawing.coord
draw(self )
Draws the coordinate system.
This method must be overridden in derived classes.
Overrides: igraph.drawing.baseclasses.AbstractDrawer.draw
local_to_context(self, x, y)
Converts local coordinates to the context coordinate system (given by the
bounding box).
This method must be overridden in derived classes.
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__str__(), __subclasshook__()
13.2.2
Properties
Name
Description
Inherited from igraph.drawing.baseclasses.AbstractCairoDrawer (Section 11.3)
bbox
Inherited from object
__class__
13.3
Class DescartesCoordinateSystem
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.baseclasses.AbstractCairoDrawer
igraph.drawing.coord.CoordinateSystem
igraph.drawing.coord.DescartesCoordinateS
Class implementing a 2D Descartes coordinate system object.
330
Class DescartesCoordinateSystem
13.3.1
Module igraph.drawing.coord
Methods
Properties
Name
bbox
bounds
Description
Returns the bounding box of the coordinate
system
Returns the lower and upper bounds of the X
and Y values
331
Module igraph.drawing.edge
14
Module igraph.drawing.edge
Class AbstractEdgeDrawer
object
igraph.drawing.edge.AbstractEdgeDrawer
Methods
332
Class AbstractEdgeDrawer
Module igraph.drawing.edge
333
Class ArrowEdgeDrawer
Module igraph.drawing.edge
Properties
Name
Inherited from object
__class__
14.2
Description
Class ArrowEdgeDrawer
object
igraph.drawing.edge.AbstractEdgeDrawer
igraph.drawing.edge.ArrowEdgeDrawer
Edge drawer implementation that draws undirected edges as straight lines and directed edges
as arrows.
334
Class TaperedEdgeDrawer
14.2.1
Module igraph.drawing.edge
Methods
Properties
Name
Inherited from object
__class__
14.3
Description
Class TaperedEdgeDrawer
object
igraph.drawing.edge.AbstractEdgeDrawer
igraph.drawing.edge.TaperedEdgeDrawer
Edge drawer implementation that draws undirected edges as straight lines and directed edges
as tapered lines that are wider at the source and narrow at the destination.
335
Class AlphaVaryingEdgeDrawer
14.3.1
Module igraph.drawing.edge
Methods
Properties
Name
Inherited from object
__class__
14.4
Description
Class AlphaVaryingEdgeDrawer
object
igraph.drawing.edge.AbstractEdgeDrawer
igraph.drawing.edge.AlphaVaryingEdgeDrawer
336
Class AlphaVaryingEdgeDrawer
Module igraph.drawing.edge
by varying the alpha value of the specified edge color between the source and the destination.
14.4.1
Methods
Properties
Name
Inherited from object
__class__
Description
337
Class LightToDarkEdgeDrawer
14.5
Module igraph.drawing.edge
Class LightToDarkEdgeDrawer
object
igraph.drawing.edge.AbstractEdgeDrawer
igraph.drawing.edge.AlphaVaryingEdgeDrawer
igraph.drawing.edge.LightToDarkEdgeDrawer
Edge drawer implementation that draws undirected edges as straight lines and directed edges
by using an alpha value of zero (total transparency) at the source and an alpha value of one
(full opacity) at the destination. The alpha value is interpolated in-between.
14.5.1
Methods
__init__(self, context)
Constructs the edge drawer.
Parameters
context: a Cairo context on which the edges will be drawn.
palette: the palette that can be used to map integer color indices
to colors when drawing edges
Overrides: object.__init__ extit(inherited documentation)
Inherited from igraph.drawing.edge.AlphaVaryingEdgeDrawer(Section 14.4)
draw_directed_edge()
Inherited from igraph.drawing.edge.AbstractEdgeDrawer(Section 14.1)
draw_loop_edge(), draw_undirected_edge(), get_label_position()
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__str__(), __subclasshook__()
14.5.2
Properties
Name
Inherited from object
__class__
Description
338
Class DarkToLightEdgeDrawer
14.6
Module igraph.drawing.edge
Class DarkToLightEdgeDrawer
object
igraph.drawing.edge.AbstractEdgeDrawer
igraph.drawing.edge.AlphaVaryingEdgeDrawer
igraph.drawing.edge.DarkToLightEdgeDrawer
Edge drawer implementation that draws undirected edges as straight lines and directed edges
by using an alpha value of one (full opacity) at the source and an alpha value of zero (total
transparency) at the destination. The alpha value is interpolated in-between.
14.6.1
Methods
__init__(self, context)
Constructs the edge drawer.
Parameters
context: a Cairo context on which the edges will be drawn.
palette: the palette that can be used to map integer color indices
to colors when drawing edges
Overrides: object.__init__ extit(inherited documentation)
Inherited from igraph.drawing.edge.AlphaVaryingEdgeDrawer(Section 14.4)
draw_directed_edge()
Inherited from igraph.drawing.edge.AbstractEdgeDrawer(Section 14.1)
draw_loop_edge(), draw_undirected_edge(), get_label_position()
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__str__(), __subclasshook__()
14.6.2
Properties
Name
Inherited from object
__class__
Description
339
Module igraph.drawing.graph
15
Module igraph.drawing.graph
Class DefaultGraphDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.graph.AbstractGraphDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.baseclasses.AbstractCairoDrawer
igraph.drawing.graph.AbstractCairoGraphDrawer
igraph.drawing.graph.DefaultGraphDrawer
Class implementing the default visualisation of a graph.
The default visualisation of a graph draws the nodes on a 2D plane according to a given
Layout, then draws a straight or curved edge between nodes connected by edges. This is
the visualisation used when one invokes the plot() function on a Graph object.
See Graph.__plot__() for the keyword arguments understood by this drawer.
6 http://www.cytoscape.org
7 http://gforge.nbic.nl/projects/cytoscaperpc/
340
Class DefaultGraphDrawer
15.1.1
Module igraph.drawing.graph
Methods
341
Class UbiGraphDrawer
Module igraph.drawing.graph
Properties
Name
Description
Inherited from igraph.drawing.baseclasses.AbstractCairoDrawer (Section 11.3)
bbox
Inherited from object
__class__
15.2
Class UbiGraphDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.baseclasses.AbstractXMLRPCDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.graph.AbstractGraphDrawer
igraph.drawing.graph.UbiGraphDrawer
Graph drawer that draws a given graph on an UbiGraph display using the XML-RPC API
of UbiGraph.
The following vertex attributes are supported: color, label, shape, size. See the Ubigraph
342
Class UbiGraphDrawer
Module igraph.drawing.graph
documentation for supported shape names. Sizes are relative to the default Ubigraph size.
The following edge attributes are supported: color, label, width. Edge widths are relative
to the default Ubigraph width.
All color specifications supported by igraph (e.g., color names, palette indices, RGB triplets,
RGBA quadruplets, HTML format) are understood by the Ubigraph graph drawer.
The drawer also has two attributes, vertex_defaults and edge_defaults. These are dictionaries that can be used to set default values for the vertex/edge attributes in Ubigraph.
15.2.1
Methods
the URL where the XML-RPC calls for the service should
be addressed to.
343
Class CytoscapeGraphDrawer
15.2.2
Module igraph.drawing.graph
Properties
Name
Inherited from object
__class__
15.3
Description
Class CytoscapeGraphDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.baseclasses.AbstractXMLRPCDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.graph.AbstractGraphDrawer
igraph.drawing.graph.CytoscapeGraphDraw
Graph drawer that sends/receives graphs to/from Cytoscape using CytoscapeRPC.
This graph drawer cooperates with Cytoscape8 using CytoscapeRPC9 . You need to install
the CytoscapeRPC plugin first and start the XML-RPC server on a given port (port 9000
by default) from the appropriate Plugins submenu in Cytoscape.
Graph, vertex and edge attributes are transferred to Cytoscape whenever possible (i.e. when
a suitable mapping exists between a Python type and a Cytoscape type). If there is no
suitable Cytoscape type for a Python type, the drawer will use a string attribute on the
Cytoscape side and invoke str() on the Python attributes.
If an attribute to be created on the Cytoscape side already exists with a different type, an
underscore will be appended to the attribute name to resolve the type conflict.
You can use the network_id attribute of this class to figure out the network ID of the last
graph drawn with this drawer.
8 http://www.cytoscape.org
9 http://wiki.nbic.nl/index.php/CytoscapeRPC
344
Class CytoscapeGraphDrawer
15.3.1
Module igraph.drawing.graph
Methods
the URL where the XML-RPC calls for the service should
be addressed to.
Overrides: igraph.drawing.baseclasses.AbstractDrawer.draw
345
Class CytoscapeGraphDrawer
Module igraph.drawing.graph
Properties
Name
Inherited from object
__class__
Description
346
Module igraph.drawing.metamagic
16
Module igraph.drawing.metamagic
347
Class AttributeSpecification
Module igraph.drawing.metamagic
Class AttributeSpecification
object
igraph.drawing.metamagic.AttributeSpecification
Class that describes how the value of a given attribute should be retrieved.
The class contains the following members:
name: the name of the attribute. This is also used when we are trying to get its value
from a vertex/edge attribute of a graph.
alt_name: alternative name of the attribute. This is used when we are trying to
get its value from a Python dict or an igraph.Configuration object. If omitted at
construction time, it will be equal to name.
default: the default value of the attribute when none of the sources we try can provide
a meaningful value.
transform: optional transformation to be performed on the attribute value. If None or
omitted, it defaults to the type of the default value.
func: when given, this function will be called with an index in order to derive the value
of the attribute.
16.1.1
Methods
Properties
348
Class AttributeCollectorBase
Module igraph.drawing.metamagic
Name
accessor
alt_name
default
func
name
transform
Inherited from object
__class__
16.2
Description
Class AttributeCollectorBase
object
igraph.drawing.metamagic.AttributeCollectorBase
Base class for attribute collector subclasses. Classes that inherit this class may use a
declarative syntax to specify which vertex or edge attributes they intend to collect. See
AttributeCollectorMeta for the details.
16.2.1
Methods
Class AttributeCollectorBase
Module igraph.drawing.metamagic
Properties
Name
Inherited from object
__class__
Description
350
Module igraph.drawing.shapes
17
Module igraph.drawing.shapes
Class ShapeDrawerDirectory
object
igraph.drawing.shapes.ShapeDrawerDirectory
Static class that resolves shape names to their corresponding shape drawer classes.
Classes that are derived from ShapeDrawer in this module are automatically registered by
ShapeDrawerDirectory when the module is loaded for the first time.
351
Class ShapeDrawerDirectory
17.1.1
Module igraph.drawing.shapes
Methods
register(cls, drawer_class)
Registers the given shape drawer class under the given names.
Parameters
drawer_class: the shape drawer class to be registered
register_namespace(cls, namespace)
Registers all ShapeDrawer classes in the given namespace
Parameters
namespace: a Python dict mapping names to Python objects.
resolve(cls, shape)
Given a shape name, returns the corresponding shape drawer class
Parameters
shape: the name of the shape
Return Value
the corresponding shape drawer class
Raises
ValueError if the shape is unknown
resolve_default(cls, shape, default=<class
igraph.drawing.shapes.NullDrawer>)
Given a shape name, returns the corresponding shape drawer class or the
given default shape drawer if the shape name is unknown.
Parameters
shape:
352
Class ShapeDrawerDirectory
17.1.2
Module igraph.drawing.shapes
Properties
Name
Inherited from object
__class__
17.1.3
Description
Class Variables
Name
known_shapes
Description
Value: {: <class
igraph.drawing.shapes.NullDrawer>,
arrow:...
353
Class TextAlignment
18
Module igraph.drawing.text
Module igraph.drawing.text
Class TextAlignment
object
igraph.drawing.text.TextAlignment
Text alignment constants.
18.1.1
Methods
Properties
Name
Inherited from object
__class__
18.1.3
Description
Class Variables
Name
BOTTOM
CENTER
LEFT
RIGHT
TOP
Value:
Value:
Value:
Value:
Value:
Description
bottom
center
left
right
top
354
Class TextDrawer
18.2
Module igraph.drawing.text
Class TextDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.baseclasses.AbstractCairoDrawer
igraph.drawing.text.TextDrawer
Class that draws text on a Cairo context.
This class supports multi-line text unlike the original Cairo text drawing methods.
18.2.1
Methods
Constructs a new instance that will draw the given text on the given Cairo
context. Parameters
context: the context on which we will draw
bbox:
Overrides: object.__init__
draw(self, wrap=False)
355
Class TextDrawer
Module igraph.drawing.text
Calculates the layout of the current text. x and y denote the coordinates
where the drawing should start. If they are both None, the current position of
the context will be used.
Vertical alignment settings are not taken into account in this method as the
text is not drawn within a box. Parameters
x:
The X coordinate of the reference point where the layout
should start. (type=float or None)
y:
width: The width of the box in which the text will be fitted. It
matters only when the text is right-aligned or centered. The
text will overflow the box if any of the lines is longer than
the box width and wrap is False. (type=float or None)
wrap: whether to allow re-wrapping of the text if it does not fit
within the given width. (type=boolean)
Return Value
a list consisting of (x, y, line) tuples where x and y refer to
reference points on the Cairo canvas and line refers to the
corresponding text that should be plotted there.
356
Class TextDrawer
Module igraph.drawing.text
Draws the text by setting up an appropriate path on the Cairo context and
filling it. x and y denote the coordinates where the drawing should start. If
they are both None, the current position of the context will be used.
Vertical alignment settings are not taken into account in this method as the
text is not drawn within a box. Parameters
x:
The X coordinate of the reference point where the drawing
should start. (type=float or None)
y:
width: The width of the box in which the text will be fitted. It
matters only when the text is right-aligned or centered. The
text will overflow the box if any of the lines is longer than
the box width. (type=float or None)
wrap: whether to allow re-wrapping of the text if it does not fit
within the given width. (type=boolean)
text_extents(self )
Properties
Name
Description
text
Returns the text to be drawn.
Inherited from igraph.drawing.baseclasses.AbstractCairoDrawer (Section 11.3)
bbox
continued on next page
357
Class TextDrawer
Module igraph.drawing.text
Name
Inherited from object
__class__
18.2.3
Description
Class Variables
Name
BOTTOM
CENTER
LEFT
RIGHT
TOP
Value:
Value:
Value:
Value:
Value:
Description
bottom
center
left
right
top
358
Module igraph.drawing.utils
19
Module igraph.drawing.utils
Class Rectangle
object
igraph.drawing.utils.Rectangle
Known Subclasses: igraph.drawing.utils.BoundingBox
Class representing a rectangle.
19.1.1
Methods
__init__(self, *args)
Creates a rectangle.
The corners of the rectangle can be specified by either a tuple (four items, two
for each corner, respectively), four separate numbers (X and Y coordinates for
each corner) or two separate numbers (width and height, the upper left corner
is assumed to be at (0,0))
Overrides: object.__init__
contract(self, margins)
Contracts the rectangle by the given margins.
Return Value
a new Rectangle object.
expand(self, margins)
Expands the rectangle by the given margins.
Return Value
a new Rectangle object.
359
Class Rectangle
Module igraph.drawing.utils
isdisjoint(self, other )
Returns True if the two rectangles have no intersection.
Example:
>>> r1 = Rectangle(10, 10, 30, 30)
>>> r2 = Rectangle(20, 20, 50, 50)
>>> r3 = Rectangle(70, 70, 90, 90)
>>> r1.isdisjoint(r2)
False
>>> r2.isdisjoint(r1)
False
>>> r1.isdisjoint(r3)
True
>>> r3.isdisjoint(r1)
True
isempty(self )
Returns True if the rectangle is empty (i.e. it has zero width and height).
Example:
>>> r1 = Rectangle(10, 10, 30, 30)
>>> r2 = Rectangle(70, 70, 90, 90)
>>> r1.isempty()
False
>>> r2.isempty()
False
>>> r1.intersection(r2).isempty()
True
360
Class Rectangle
Module igraph.drawing.utils
intersection(self, other )
Returns the intersection of this rectangle with another.
Example:
>>> r1 = Rectangle(10, 10, 30, 30)
>>> r2 = Rectangle(20, 20, 50, 50)
>>> r3 = Rectangle(70, 70, 90, 90)
>>> r1.intersection(r2)
Rectangle(20.0, 20.0, 30.0, 30.0)
>>> r2 & r1
Rectangle(20.0, 20.0, 30.0, 30.0)
>>> r2.intersection(r1) == r1.intersection(r2)
True
>>> r1.intersection(r3)
Rectangle(0.0, 0.0, 0.0, 0.0)
__and__(self, other )
Returns the intersection of this rectangle with another.
Example:
>>> r1 = Rectangle(10, 10, 30, 30)
>>> r2 = Rectangle(20, 20, 50, 50)
>>> r3 = Rectangle(70, 70, 90, 90)
>>> r1.intersection(r2)
Rectangle(20.0, 20.0, 30.0, 30.0)
>>> r2 & r1
Rectangle(20.0, 20.0, 30.0, 30.0)
>>> r2.intersection(r1) == r1.intersection(r2)
True
>>> r1.intersection(r3)
Rectangle(0.0, 0.0, 0.0, 0.0)
361
Class Rectangle
Module igraph.drawing.utils
Parameters
dx: the X coordinate of the translation vector
dy: the Y coordinate of the translation vector
union(self, other )
Returns the union of this rectangle with another.
The resulting rectangle is the smallest rectangle that contains both rectangles.
Example:
>>> r1 = Rectangle(10, 10, 30, 30)
>>> r2 = Rectangle(20, 20, 50, 50)
>>> r3 = Rectangle(70, 70, 90, 90)
>>> r1.union(r2)
Rectangle(10.0, 10.0, 50.0, 50.0)
>>> r2 | r1
Rectangle(10.0, 10.0, 50.0, 50.0)
>>> r2.union(r1) == r1.union(r2)
True
>>> r1.union(r3)
Rectangle(10.0, 10.0, 90.0, 90.0)
362
Class Rectangle
Module igraph.drawing.utils
__or__(self, other )
Returns the union of this rectangle with another.
The resulting rectangle is the smallest rectangle that contains both rectangles.
Example:
>>> r1 = Rectangle(10, 10, 30, 30)
>>> r2 = Rectangle(20, 20, 50, 50)
>>> r3 = Rectangle(70, 70, 90, 90)
>>> r1.union(r2)
Rectangle(10.0, 10.0, 50.0, 50.0)
>>> r2 | r1
Rectangle(10.0, 10.0, 50.0, 50.0)
>>> r2.union(r1) == r1.union(r2)
True
>>> r1.union(r3)
Rectangle(10.0, 10.0, 90.0, 90.0)
__ior__(self, other )
Expands this rectangle to include itself and another completely while still
being as small as possible.
Example:
>>> r1 = Rectangle(10, 10, 30, 30)
>>> r2 = Rectangle(20, 20, 50, 50)
>>> r3 = Rectangle(70, 70, 90, 90)
>>> r1 |= r2
>>> r1
Rectangle(10.0, 10.0, 50.0, 50.0)
>>> r1 |= r3
>>> r1
Rectangle(10.0, 10.0, 90.0, 90.0)
__repr__(self )
repr(x)
Overrides: object.__repr__ extit(inherited documentation)
__eq__(self, other )
__ne__(self, other )
363
Class BoundingBox
Module igraph.drawing.utils
__bool__(self )
__nonzero__(self )
__hash__(self )
hash(x)
Overrides: object.__hash__ extit(inherited documentation)
Inherited from object
__delattr__(), __format__(), __getattribute__(), __new__(), __reduce__(),
__reduce_ex__(), __setattr__(), __sizeof__(), __str__(), __subclasshook__()
19.1.2
Properties
Name
coords
width
height
left
right
top
bottom
midx
midy
shape
Inherited from object
__class__
19.2
Description
The coordinates of the corners.
The coordinates are returned as a 4-tuple in the
following order: left edge, top edge, right edge,
bottom edge.
The width of the rectangle
The height of the rectangle
The X coordinate of the left side of the box
The X coordinate of the right side of the box
The Y coordinate of the top edge of the box
The Y coordinate of the bottom edge of the box
The X coordinate of the center of the box
The Y coordinate of the center of the box
The shape of the rectangle (width, height)
Class BoundingBox
object
igraph.drawing.utils.Rectangle
igraph.drawing.utils.BoundingBox
Class representing a bounding box (a rectangular area) that encloses some objects.
364
Class BoundingBox
19.2.1
Module igraph.drawing.utils
Methods
__ior__(self, other )
Replaces this bounding box with the union of itself and another.
Example:
>>> box1 = BoundingBox(10, 20, 50, 60)
>>> box2 = BoundingBox(70, 40, 100, 90)
>>> box1 |= box2
>>> print(box1)
BoundingBox(10.0, 20.0, 100.0, 90.0)
Overrides: igraph.drawing.utils.Rectangle.__ior__
__or__(self, other )
Takes the union of this bounding box with another.
The result is a bounding box which encloses both bounding boxes.
Example:
>>> box1 = BoundingBox(10, 20, 50, 60)
>>> box2 = BoundingBox(70, 40, 100, 90)
>>> box1 | box2
BoundingBox(10.0, 20.0, 100.0, 90.0)
Overrides: igraph.drawing.utils.Rectangle.__or__
Inherited from igraph.drawing.utils.Rectangle(Section 19.1)
__and__(), __bool__(), __eq__(), __hash__(), __init__(), __ne__(),
__nonzero__(), __repr__(), contract(), expand(), intersection(), isdisjoint(),
isempty(), translate(), union()
Inherited from object
__delattr__(), __format__(), __getattribute__(), __new__(), __reduce__(),
__reduce_ex__(), __setattr__(), __sizeof__(), __str__(), __subclasshook__()
19.2.2
Properties
Name
Description
Inherited from igraph.drawing.utils.Rectangle (Section 19.1)
bottom, coords, height, left, midx, midy, right, shape, top, width
Inherited from object
continued on next page
365
Class FakeModule
Module igraph.drawing.utils
Name
__class__
19.3
Description
Class FakeModule
object
igraph.drawing.utils.FakeModule
Fake module that raises an exception for everything
19.3.1
Methods
__getattr__(self, _)
__call__(self, _)
__setattr__(self, key, value)
x.__setattr__(name, value) <==> x.name = value
Overrides: object.__setattr__ extit(inherited documentation)
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __init__(),
__new__(), __reduce__(), __reduce_ex__(), __repr__(), __sizeof__(),
__str__(), __subclasshook__()
19.3.2
Properties
Name
Inherited from object
__class__
Description
366
Class Point
19.4
Module igraph.drawing.utils
Class Point
object
tuple
igraph.drawing.utils.Point
Class representing a point on the 2D plane.
19.4.1
Methods
__new__(cls, x, y)
Creates a new point with the given coordinates
Return Value
a new object with type S, a subtype of T
Overrides: object.__new__
__repr__(self )
Returns a nicely formatted representation of the point
Overrides: object.__repr__
__getnewargs__(self )
Return self as a plain tuple. Used by copy and pickle.
Overrides: tuple.__getnewargs__
__add__(self, other )
Adds the coordinates of a point to another one
Overrides: tuple.__add__
__sub__(self, other )
Subtracts the coordinates of a point to another one
__mul__(self, scalar )
Multiplies the coordinates by a scalar
Overrides: tuple.__mul__
367
Class Point
Module igraph.drawing.utils
__rmul__(self, scalar )
Multiplies the coordinates by a scalar
Overrides: tuple.__rmul__
__div__(self, scalar )
Divides the coordinates by a scalar
as_polar(self )
Returns the polar coordinate representation of the point.
Return Value
the radius and the angle in a tuple.
distance(self, other )
Returns the distance of the point from another one.
Example:
>>>
>>>
>>>
p1 = Point(5, 7)
p2 = Point(8, 3)
p1.distance(p2)
5.0
Class Point
Module igraph.drawing.utils
Properties
Name
x
y
Inherited from object
__class__
Description
Alias for field number 0
Alias for field number 1
369
Module igraph.drawing.vertex
20
Module igraph.drawing.vertex
Class AbstractVertexDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.vertex.AbstractVertexDrawer
Known Subclasses: igraph.drawing.vertex.AbstractCairoVertexDrawer
Abstract vertex drawer object from which all concrete vertex drawer implementations are
derived.
20.1.1
Methods
370
Class AbstractCairoVertexDrawer
Module igraph.drawing.vertex
coords:
Overrides: igraph.drawing.baseclasses.AbstractDrawer.draw
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__str__(), __subclasshook__()
20.1.2
Properties
Name
Inherited from object
__class__
20.2
Description
Class AbstractCairoVertexDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.vertex.AbstractVertexDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.baseclasses.AbstractCairoDrawer
igraph.drawing.vertex.AbstractCairoVertexDra
371
Class AbstractCairoVertexDrawer
Module igraph.drawing.vertex
Methods
palette: the palette that can be used to map integer color indices
to colors when drawing vertices
layout: the layout of the vertices in the graph being drawn
Overrides: object.__init__
Inherited from igraph.drawing.vertex.AbstractVertexDrawer(Section 20.1)
draw()
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__str__(), __subclasshook__()
20.2.2
Properties
Name
Description
Inherited from igraph.drawing.baseclasses.AbstractCairoDrawer (Section 11.3)
bbox
Inherited from object
__class__
372
Class DefaultVertexDrawer
20.3
Module igraph.drawing.vertex
Class DefaultVertexDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.vertex.AbstractVertexDrawer
object
igraph.drawing.baseclasses.AbstractDrawer
igraph.drawing.baseclasses.AbstractCairoDrawer
igraph.drawing.vertex.AbstractCairoVertexDrawer
igraph.drawing.vertex.DefaultVertexDrawe
The default vertex drawer implementation of igraph.
20.3.1
Methods
palette: the palette that can be used to map integer color indices
to colors when drawing vertices
layout: the layout of the vertices in the graph being drawn
Overrides: object.__init__ extit(inherited documentation)
373
Class DefaultVertexDrawer
Module igraph.drawing.vertex
coords:
Properties
Name
Description
Inherited from igraph.drawing.baseclasses.AbstractCairoDrawer (Section 11.3)
bbox
Inherited from object
__class__
374
Class Layout
21
Module igraph.layout
Module igraph.layout
Variables
Name
__package__
21.2
Description
Value: igraph
Class Layout
object
igraph.layout.Layout
Represents the layout of a graph.
A layout is practically a list of coordinates in an n-dimensional space. This class is generic
in the sense that it can store coordinates in any n-dimensional space.
Layout objects are not associated directly with a graph. This is deliberate: there were times
when I worked with almost identical copies of the same graph, the only difference was that
they had different colors assigned to the vertices. It was particularly convenient for me to
use the same layout for all of them, especially when I made figures for a paper. However,
igraph will of course refuse to draw a graph with a layout that has less coordinates than
the node count of the graph.
Layouts behave exactly like lists when they are accessed using the item index operator
375
Class Layout
Module igraph.layout
([...]). They can even be iterated through. Items returned by the index operator are only
copies of the coordinates, but the stored coordinates can be modified by directly assigning
to an index.
>>>
>>>
>>>
[0, 2]
>>>
coords = (0, 3)
layout[1]
>>> print
[0, 2]
>>>
layout[1] = coords
layout[1]
>>> print
[0, 3]
21.2.1
Methods
Overrides: object.__init__
__len__(self )
__getitem__(self, idx )
__setitem__(self, idx, value)
__delitem__(self, idx )
__copy__(self )
376
Class Layout
Module igraph.layout
__repr__(self )
repr(x)
Overrides: object.__repr__ extit(inherited documentation)
append(self, value)
Appends a new point to the layout
mirror(self, dim)
Mirrors the layout along the given dimension(s)
Parameters
dim: the list of dimensions or a single dimension
rotate(self, angle, dim1 =0, dim2 =1, **kwds)
Rotates the layout by the given degrees on the plane defined by the given two
dimensions.
Parameters
angle: the angle of the rotation, specified in degrees.
dim1:
dim2:
origin: the origin of the rotation. If not specified, the origin will be
the origin of the coordinate system.
scale(self, *args, **kwds)
Scales the layout.
Scaling parameters can be provided either through the scale keyword
argument or through plain unnamed arguments. If a single integer or float is
given, it is interpreted as a uniform multiplier to be applied on all dimensions.
If it is a list or tuple, its length must be equal to the number of dimensions in
the layout, and each element must be an integer or float describing the scaling
coefficient in one of the dimensions.
Parameters
scale: scaling coefficients (integer, float, list or tuple)
origin: the origin of scaling (this point will stay in place).
Optional, defaults to the origin of the coordinate system
being used.
377
Class Layout
Module igraph.layout
378
Class Layout
Module igraph.layout
379
Class Layout
Module igraph.layout
380
Class Layout
Module igraph.layout
Properties
Name
dim
coords
Inherited from object
__class__
Description
Returns the number of dimensions
The coordinates as a list of lists
381
Class Matching
22
Module igraph.matching
Module igraph.matching
Variables
Name
__package__
22.2
Description
Value: igraph
Class Matching
object
igraph.matching.Matching
A matching of vertices in a graph.
A matching of an undirected graph is a set of edges such that each vertex is incident on
at most one matched edge. When each vertex is incident on exactly one matched edge, the
matching called perfect. This class is used in igraph to represent non-perfect and perfect
matchings in undirected graphs.
This class is usually not instantiated directly, everything is taken care of by the functions
that return matchings.
Examples:
igraph import Graph
g = Graph.Famous("noperfectmatching")
matching = g.maximum_matching()
>>> from
>>>
>>>
382
Class Matching
22.2.1
Module igraph.matching
Methods
Raises
ValueError if the matching vector supplied does not describe a
valid matching of the graph.
Overrides: object.__init__
__len__(self )
__repr__(self )
repr(x)
Overrides: object.__repr__ extit(inherited documentation)
__str__(self )
str(x)
Overrides: object.__str__ extit(inherited documentation)
edges(self )
Returns an edge sequence that contains the edges in the matching.
If there are multiple edges between a pair of matched vertices, only one of
them will be returned.
383
Class Matching
Module igraph.matching
is_maximal(self )
Returns whether the matching is maximal.
A matching is maximal when it is not possible to extend it any more with
extra edges; in other words, unmatched vertices in the graph must be adjacent
to matched vertices only.
is_matched(self, vertex )
Returns whether the given vertex is matched to another one.
match_of (self, vertex )
Returns the vertex a given vertex is matched to.
Parameters
vertex: the vertex we are interested in; either an integer index or
an instance of Vertex.
Return Value
the index of the vertex matched to the given vertex, either as an
integer index (if vertex was integer) or as an instance of Vertex.
When the vertex is unmatched, returns None.
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __setattr__(), __sizeof__(), __subclasshook__()
22.2.2
Properties
Name
graph
matching
types
Description
Returns the graph corresponding to the
matching.
Returns the matching vector where element i
contains the ID of the vertex that vertex i is
matched to.
The matching vector will contain -1 for
unmatched vertices.
Returns the type vector if the graph is bipartite.
Element i of the type vector will be False or
True depending on which side of the bipartite
graph vertex i belongs to.
For non-bipartite graphs, this property returns
None.
continued on next page
384
Class Matching
Module igraph.matching
Name
Inherited from object
__class__
Description
385
Variables
23
Package igraph.remote
Package igraph.remote
Modules
Variables
Name
__package__
Description
Value: None
386
Module igraph.remote.gephi
24
Module igraph.remote.gephi
Class GephiConnection
object
igraph.remote.gephi.GephiConnection
Object that represents a connection to a Gephi master server.
24.1.1
Methods
Class GephiConnection
Module igraph.remote.gephi
__del__(self )
close(self )
Flushes all the pending operations to the Gephi master server in a single
request.
flush(self )
Flushes all the pending operations to the Gephi master server in a single
request.
write(self, data)
Sends the given raw data to the Gephi streaming master server in an HTTP
POST request.
__repr__(self )
repr(x)
Overrides: object.__repr__ extit(inherited documentation)
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __setattr__(), __sizeof__(), __str__(),
__subclasshook__()
24.1.2
Properties
Name
url
Description
The URL of the Gephi workspace where the
data will be sent.
388
Class GephiGraphStreamingAPIFormat
24.2
Module igraph.remote.gephi
Class GephiGraphStreamingAPIFormat
object
igraph.remote.gephi.GephiGraphStreamingAPIFormat
Object that implements the Gephi graph streaming API format and returns Python objects
corresponding to the events defined in the API.
24.2.1
Methods
Generates a Python object corresponding to the event that adds a node with
the given identifier and attributes in the Gephi graph streaming API.
Example:
>>> api = GephiGraphStreamingAPIFormat()
>>> api.get_add_node_event("spam")
{an: {spam: {}}}
>>> api.get_add_node_event("spam", dict(ham="eggs"))
{an: {spam: {ham: eggs}}}
get_add_edge_event(self, identifier, source, target, directed, attributes={})
Generates a Python object corresponding to the event that adds an edge with
the given source, target, directednessr and attributes in the Gephi graph
streaming API.
389
Class GephiGraphStreamingAPIFormat
Module igraph.remote.gephi
390
Class GephiGraphStreamer
Module igraph.remote.gephi
get_delete_edge_event(self, identifier )
Properties
Name
Inherited from object
__class__
24.3
Description
Class GephiGraphStreamer
object
igraph.remote.gephi.GephiGraphStreamer
Class that produces JSON event objects that stream an igraph graph to Gephi using the
Gephi Graph Streaming API.
The Gephi graph streaming format is a simple JSON-based format that can be used to post
mutations to a graph (i.e. node and edge additions, removals and updates) to a remote
component. For instance, one can open up Gephi (http://www.gephi.org}), install the
Gephi graph streaming plugin and then send a graph from igraph straight into the Gephi
window by using GephiGraphStreamer with the appropriate URL where Gephi is listening.
Example:
>>> from cStringIO import StringIO
>>> from igraph import Graph
>>> buf = StringIO()
391
Class GephiGraphStreamer
Module igraph.remote.gephi
Methods
Constructs a Gephi graph streamer that will post graphs to a given file-like
object or a Gephi connection.
encoder must either be None or an instance of json.JSONEncoder and it must
contain the JSON encoder to be used when posting JSON objects. Overrides:
object.__init__
iterjsonobj(self, graph)
Iterates over the JSON objects that build up the graph using the Gephi graph
streaming API. The objects returned from this function are Python objects;
they must be formatted with json.dumps before sending them to the
destination.
post(self, graph, destination, encoder =None)
Posts the given graph to the destination of the streamer using the given JSON
encoder. When encoder is None, it falls back to the default JSON encoder of
the streamer in the encoder property.
destination must be a file-like object or an instance of GephiConnection.
392
Class GephiGraphStreamer
Module igraph.remote.gephi
Sends a single JSON event to the given destination using the given JSON
encoder. When encoder is None, it falls back to the default JSON encoder of
the streamer in the encoder property.
destination must be a file-like object or an instance of GephiConnection.
The method flushes the destination after sending the event. If you want to
avoid this (e.g., because you are sending many events), set flush to False.
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__str__(), __subclasshook__()
24.3.2
Properties
Name
Inherited from object
__class__
Description
393
Class NexusConnection
25
Module igraph.remote.nexus
Module igraph.remote.nexus
Variables
Name
Nexus
25.2
Description
Value: NexusConnection()
Class NexusConnection
object
igraph.remote.nexus.NexusConnection
Connection to a remote Nexus server.
In most cases, you will not have to instantiate this object, just use the global Nexus variable which is an instance of NexusConnection and connects to the Nexus repository at
http://nexus.igraph.org.
Example:
394
Class NexusConnection
Nexus.info("karate")
Module igraph.remote.nexus
#doctest:+ELLIPSIS
karate = Nexus.get("karate")
igraph import summary
summary(karate)
>>> from
>>>
25.2.1
Methods
395
Class NexusConnection
Module igraph.remote.nexus
get(self, id )
Retrieves the dataset with the given ID from Nexus.
Dataset IDs are formatted as follows: the name of a dataset on its own means
that a single network should be returned if the dataset contains a single
network, or multiple networks should be returned if the dataset contains
multiple networks. When the name is followed by a dot and a network ID,
only a single network will be returned: the one that has the given network ID.
When the name is followed by a dot and a star, a dictionary mapping network
IDs to networks will be returned even if the original dataset contains a single
network only.
E.g., getting "karate" would return a single network since the Zachary karate
club dataset contains one network only. Getting "karate.*" on the other
hand would return a dictionary with one entry that contains the Zachary
karate club network.
Parameters
id: the ID of the dataset to retrieve.
Return Value
an instance of Graph (if a single graph has to be returned) or a
dictionary mapping network IDs to instances of Graph.
info(self, id )
Retrieves informations about the dataset with the given numeric or string ID
from Nexus.
Parameters
id: the numeric or string ID of the dataset to retrieve.
Return Value
an instance of NexusDatasetInfo.
396
Class NexusConnection
Module igraph.remote.nexus
Return Value
a NexusDatasetInfoList object, which basically acts like a list and
yields NexusDatasetInfo objects. The list is populated lazily; i.e.
the requests will be fired only when needed.
search(self, query, order =date)
Retrieves a list of datasets matching a query string from Nexus.
Parameters
query: the query string. Searches are case insensitive and Nexus
searches for complete words only. The special word OR can
be used to find datasets that contain any of the given words
(instead of all of them). Exact phrases must be enclosed in
quotes in the search string. See the Nexus webpage for more
information at http://nexus.igraph.org/web/docs#searching.
order: the order of entries; it must be one of "date", "name" or
"popularity".
Return Value
a NexusDatasetInfoList object, which basically acts like a list and
yields NexusDatasetInfo objects. The list is populated lazily; i.e.
the requests will be fired only when needed.
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __repr__(), __setattr__(), __sizeof__(),
__str__(), __subclasshook__()
25.2.2
Properties
397
Class NexusConnection
Name
url
Module igraph.remote.nexus
Description
Returns the root URL of the Nexus repository
the connection is communicating with.
398
Module igraph.statistics
26
Module igraph.statistics
Functions
mean(xs)
Returns the mean of an iterable.
Example:
>>>
mean([1, 4, 7, 11])
5.75
Parameters
xs: an iterable yielding numbers.
Return Value
the mean of the numbers provided by the iterable.
See Also: RunningMean() if you also need the variance or the standard
deviation
399
Functions
Module igraph.statistics
median(xs, sort=True)
Returns the median of an unsorted or sorted numeric vector.
Parameters
xs: the vector itself.
sort: whether to sort the vector. If you know that the vector is
sorted already, pass False here.
Return Value
the median, which will always be a float, even if the vector contained
integers originally.
percentile(xs, p=(25, 50, 75), sort=True)
Returns the pth percentile of an unsorted or sorted numeric vector.
This is equivalent to calling quantile(xs, p/100.0); see quantile for more
details on the calculation.
Example:
>>>
26.0
>>> for
...
perc
print
percentile([15, 20, 40, 35, 50], (0, 25, 50, 75, 100)):
"%.2f" % perc
in
...
15.00
17.50
35.00
45.00
50.00
Parameters
xs: the vector itself.
p:
sort: whether to sort the vector. If you know that the vector is
sorted already, pass False here.
Return Value
the pth percentile, which will always be a float, even if the vector
contained integers originally. If p is a list, the result will also be a
list containing the percentiles for each item in the list.
400
Functions
Module igraph.statistics
401
Class FittedPowerLaw
Module igraph.statistics
26.0
Parameters
xs: the vector itself.
the quantile we are looking for. It may also be a list if you
want to calculate multiple quantiles with a single call. The
default value calculates the 25th, 50th and 75th percentile.
q:
sort: whether to sort the vector. If you know that the vector is
sorted already, pass False here.
Return Value
the qth quantile, which will always be a float, even if the vector
contained integers originally. If q is a list, the result will also be a
list containing the quantiles for each item in the list.
26.2
Class FittedPowerLaw
object
igraph.statistics.FittedPowerLaw
Result of fitting a power-law to a vector of samples
Example:
>>>
>>>
result
# doctest:+ELLIPSIS
= 2.425828
402
Class FittedPowerLaw
Cutoff (xmin)
Module igraph.statistics
= 3.000000
<BLANKLINE>
Log-likelihood
= -7.546337
<BLANKLINE>
H0: data was drawn from the fitted distribution
<BLANKLINE>
KS test statistic = 0.213817
p-value
= 0.993111
<BLANKLINE>
H0 could not be rejected at significance level 0.05
>>>
result.alpha
# doctest:+ELLIPSIS
2.425828...
>>>
result.xmin
3.0
>>>
result.continuous
False
26.2.1
Methods
403
Class Histogram
Module igraph.statistics
summary(self, significance=0.05)
Returns the summary of the power law fit.
Parameters
significance: the significance level of the Kolmogorov-Smirnov
test used to decide whether the input data could
have come from the fitted distribution
Return Value
the summary as a string
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __setattr__(), __sizeof__(), __subclasshook__()
26.2.2
Properties
Name
Inherited from object
__class__
26.3
Description
Class Histogram
object
igraph.statistics.Histogram
Generic histogram class for real numbers
Example:
>>>
>>>
>>>
h = Histogram(5)
# Initializing, bin width = 5
h << [2,3,2,7,8,5,5,0,7,9]
# Adding more items
print h
404
Class Histogram
26.3.1
Module igraph.statistics
Methods
Overrides: object.__init__
add(self, num, repeat=1)
Adds a single number to the histogram.
Parameters
num:
the number to be added
repeat: number of repeated additions
add_many(self, data)
Adds a single number or the elements of an iterable to the histogram.
Parameters
data: the data to be added
__lshift__(self, data)
Adds a single number or the elements of an iterable to the histogram.
Parameters
data: the data to be added
clear(self )
Clears the collected data
bins(self )
Generator returning the bins of the histogram in increasing order
Return Value
a tuple with the following elements: left bound, right bound, number
of elements in the bin
__plot__(self, context, bbox, _, **kwds)
Plotting support
405
Class Histogram
Module igraph.statistics
Properties
Name
n
mean
sd
var
Description
Returns the number of elements in the
histogram
Returns the mean of the elements in the
histogram
Returns the standard deviation of the elements
in the histogram
Returns the variance of the elements in the
histogram
406
Class RunningMean
26.4
Module igraph.statistics
Class RunningMean
object
igraph.statistics.RunningMean
Running mean calculator.
This class can be used to calculate the mean of elements from a list, tuple, iterable or any
other data source. The mean is calculated on the fly without explicitly summing the values,
so it can be used for data sets with arbitrary item count. Also capable of returning the
standard deviation (also calculated on the fly)
26.4.1
Methods
Overrides: object.__init__
add(RunningMean, value, repeat=1)
Adds the given value to the elements from which we calculate the mean and
the standard deviation.
Parameters
value: the element to be added
repeat: number of repeated additions
407
Class RunningMean
Module igraph.statistics
add_many(RunningMean, values)
Adds the values in the given iterable to the elements from which we calculate
the mean. Can also accept a single number. The left shift (<<) operator is
aliased to this function, so you can use it to add elements as well:
>>>
>>>
>>>
rm=RunningMean()
rm << [1,2,3,4]
rm.result
# doctest:+ELLIPSIS
(2.5, 1.290994...)
Parameters
values: the element(s) to be added
(type=iterable)
clear(self )
Resets the running mean calculator.
__repr__(self )
repr(x)
Overrides: object.__repr__ extit(inherited documentation)
__str__(self )
str(x)
Overrides: object.__str__ extit(inherited documentation)
__lshift__(RunningMean, values)
Adds the values in the given iterable to the elements from which we calculate
the mean. Can also accept a single number. The left shift (<<) operator is
aliased to this function, so you can use it to add elements as well:
>>>
>>>
>>>
rm=RunningMean()
rm << [1,2,3,4]
rm.result
# doctest:+ELLIPSIS
(2.5, 1.290994...)
Parameters
values: the element(s) to be added
(type=iterable)
__float__(self )
408
Class RunningMean
Module igraph.statistics
__int__(self )
__long__(self )
__complex__(self )
__len__(self )
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
__reduce__(), __reduce_ex__(), __setattr__(), __sizeof__(), __subclasshook__()
26.4.2
Properties
Name
result
mean
sd
var
Inherited from object
__class__
Description
Returns the current mean and standard
deviation as a tuple
Returns the current mean
Returns the current standard deviation
Returns the current variation
409
Module igraph.summary
27
Module igraph.summary
Class GraphSummary
object
igraph.summary.GraphSummary
Summary representation of a graph.
The summary representation includes a header line and the list of edges. The header line
consists of IGRAPH, followed by a four-character long code, the number of vertices, the number
of edges, two dashes () and the name of the graph (i.e. the contents of the name attribute,
if any). For instance, a header line may look like this:
IGRAPH U--- 4 5 -The four-character code describes some basic properties of the graph. The first character is
U if the graph is undirected, D if it is directed. The second letter is N if the graph has a vertex
attribute called name, or a dash otherwise. The third letter is W if the graph is weighted (i.e.
it has an edge attribute called weight), or a dash otherwise. The fourth letter is B if the
graph has a vertex attribute called type; this is usually used for bipartite graphs.
Edges may be presented as an ordinary edge list or an adjacency list. By default, this
depends on the number of edges; however, you can control it with the appropriate constructor
arguments.
410
Class GraphSummary
27.1.1
Module igraph.summary
Methods
width:
max_rows:
edge_list_format:
full:
Overrides: object.__init__
__str__(self )
Returns the summary representation as a string.
Overrides: object.__str__
Inherited from object
__delattr__(), __format__(), __getattribute__(), __hash__(), __new__(),
411
Class GraphSummary
Module igraph.summary
Properties
Name
Inherited from object
__class__
Description
412
Module igraph.utils
28
Module igraph.utils
Utility functions that cannot be categorised anywhere else License: Copyright (C) 2006-2012
Tams Nepusz <ntamas@gmail.com> Pzmny Pter stny 1/a, 1117 Budapest, Hungary
This program is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version
2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program;
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
28.1
Functions
named_temporary_file(*args, **kwds)
Context manager that creates a named temporary file and returns its name.
All parameters are passed on to tempfile.mkstemp, see its documentation for
more info.
413
Functions
Module igraph.utils
>>> from
>>>
rescale([1, 10, 100, 1000, 10000], (0, 4), (10, 1000), scale=log10)
414
Variables
Module igraph.utils
safemax(iterable, default=0)
Safer variant of max() that returns a default value if the iterable is empty.
Example:
>>>
safemax([-5, 6, 4])
6
>>>
safemax([])
0
>>>
safemax((), 2)
safemin(iterable, default=0)
Safer variant of min() that returns a default value if the iterable is empty.
Example:
>>>
safemin([-5, 6, 4])
-5
>>>
safemin([])
0
>>>
safemin((), 2)
28.2
Variables
Name
dbl_epsilon
Description
Value: 2.22044604925e-16
415
Class multidict
28.3
Module igraph.utils
Class multidict
object
_abcoll.Sized
object
_abcoll.Iterable
object
_abcoll.Container
_abcoll.Mapping
_abcoll.MutableMapping
igraph.utils.multidict
A dictionary-like object that is customized to deal with multiple values for the same key.
Each value in this dictionary will be a list. Methods which emulate the methods of a standard
Python dict object will return or manipulate the first items of the lists only. Special methods
are provided to deal with keys having multiple values.
28.3.1
Methods
Returns whether there are any items associated to the given key. Overrides:
_abcoll.Container.__contains__
416
Class multidict
Module igraph.utils
__delitem__(self, key)
d = multidict([("spam",
d["spam"]
"eggs"),
("spam",
"bacon")])
eggs
Overrides: _abcoll.Mapping.__getitem__
__iter__(self )
417
Class multidict
Module igraph.utils
Sets the item associated to the given key. Any values associated to the key
will be erased and replaced by value.
Example:
>>>
>>>
>>>
d = multidict([("spam",
d["spam"] = "ham"
d["spam"]
"eggs"),
("spam",
"bacon")])
ham
Overrides: _abcoll.MutableMapping.__setitem__
add(self, key, value)
d = multidict()
d.add("spam", "ham")
d["spam"]
ham
>>>
>>>
d.add("spam", "eggs")
d.getlist("spam")
[ham, eggs]
clear(self )
418
Class multidict
Module igraph.utils
Returns an arbitrary item associated to the given key. If key does not exist or
has zero associated items, default will be returned. Return Value
D[k] if k in D, else d
Overrides: _abcoll.Mapping.get
getlist(self, key)
Returns the list of values for the given key. An empty list will be returned if
there is no such key.
iterlists(self )
Iterates over (key, values) pairs where values is the list of values
associated with key.
lists(self )
Returns a list of (key, values) pairs where values is the list of values
associated with key.
update(self, arg, **kwds)
Update D from mapping/iterable E and F. If E present and has a .keys()
method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method,
does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in
F.items(): D[k] = v
Return Value
None
Overrides: _abcoll.MutableMapping.update extit(inherited documentation)
Inherited from _abcoll.MutableMapping
pop(), popitem(), setdefault()
Inherited from _abcoll.Mapping
__eq__(), __ne__(), items(), iteritems(), iterkeys(), itervalues(), keys(), val419
Class multidict
Module igraph.utils
ues()
Inherited from _abcoll.Sized
__subclasshook__()
Inherited from object
__delattr__(), __format__(), __getattribute__(), __new__(), __reduce__(),
__reduce_ex__(), __repr__(), __setattr__(), __sizeof__(), __str__()
28.3.2
Properties
Name
Inherited from object
__class__
28.3.3
Description
Class Variables
Name
Description
__abstractmethods__
Value: frozenset([])
Inherited from _abcoll.Mapping
__hash__
420
Index
igraph.configuration (module), 261266
igraph (package), 2215
igraph._igraph (module), 216220
igraph.configuration.Configuration (class),
igraph._igraph.convex_hull (function),
262266
216
igraph.configuration.get_platform_image_viewer
igraph._igraph.InternalError (class), 219
(function), 261
220
igraph.configuration.get_user_config_file
igraph._igraph.is_degree_sequence (func(function), 261
tion), 216
igraph.configuration.init (function), 261
igraph._igraph.is_graphical_degree_sequence
igraph.cut (module), 267273
(function), 217
igraph.cut.Cut (class), 267270
igraph._igraph.set_progress_handler (func- igraph.cut.Flow (class), 270273
igraph.datatypes (module), 274285
tion), 217
igraph._igraph.set_random_number_generator
igraph.datatypes.DyadCensus (class), 279
(function), 218
281
igraph._igraph.set_status_handler (funcigraph.datatypes.Matrix (class), 274279
tion), 218
igraph.datatypes.TriadCensus (class), 281
igraph.app (package), 221
283
igraph.app.shell (module), 222231
igraph.datatypes.UniqueIdGenerator (class),
igraph.ARPACKOptions (class), 9799
283285
igraph.autocurve (function), 4
igraph.drawing (package), 286305
igraph.BFSIter (class), 99
igraph.drawing.baseclasses (module), 306
igraph.BFSIter.__iter__ (method), 99
309
igraph.BFSIter.next (method), 99
igraph.drawing.colors (module), 310322
igraph.clustering (module), 232259
igraph.drawing.coord (module), 323325
igraph.clustering.Clustering (class), 236
igraph.drawing.edge (module), 326334
239
igraph.drawing.graph (module), 334340
igraph.clustering.CohesiveBlocks (class),
igraph.drawing.metamagic (module), 341
256259
344
igraph.clustering.compare_communities
igraph.drawing.Plot (class), 301305
(function), 234
igraph.drawing.plot (function), 288
igraph.clustering.Cover (class), 250253
igraph.drawing.shapes (module), 345347
igraph.clustering.Dendrogram (class), 245
igraph.drawing.text (module), 348352
248
igraph.drawing.utils (module), 353363
igraph.clustering.split_join_distance (func- igraph.drawing.vertex (module), 364368
tion), 234
igraph.Edge (class), 99103
igraph.clustering.VertexClustering (class),
igraph.Edge.__delitem__ (method), 100
239245
igraph.Edge.__eq__ (method), 100
igraph.clustering.VertexCover (class), 253
igraph.Edge.__ge__ (method), 100
256
igraph.Edge.__getitem__ (method), 100
igraph.clustering.VertexDendrogram (class), igraph.Edge.__gt__ (method), 100
248250
igraph.Edge.__le__ (method), 100
igraph.compat (module), 260
igraph.Edge.__len__ (method), 100
421
INDEX
INDEX
(method), 25
igraph.Graph.Bipartite (class method),
61
igraph.Graph.clusters (method), 26
igraph.Graph.cohesion (method), 14, 16,
211
igraph.Graph.community_leading_eigenvector_naive
(method), 37
igraph.Graph.count_automorphisms_vf2
(method), 35
igraph.Graph.cut_vertices (method), 13,
125
igraph.Graph.degree_distribution (method),
26
igraph.Graph.DictList (class method), 58
igraph.Graph.edge_disjoint_paths (method),
15, 17, 154
igraph.Graph.evcent (method), 13, 154
igraph.Graph.Formula (class method),
60
igraph.Graph.Full_Bipartite (class method),
62
igraph.Graph.get_adjedgelist (method),
28
igraph.Graph.get_adjlist (method), 27
igraph.Graph.get_automorphisms_vf2
(method), 36
igraph.Graph.get_inclist (method), 28
igraph.Graph.GRG (class method), 64
igraph.Graph.Incidence (class method),
64
igraph.Graph.indegree (method), 23
igraph.Graph.is_named (method), 29
igraph.Graph.is_weighted (method), 29
igraph.Graph.k_core (method), 45
igraph.Graph.layout (method), 45
igraph.Graph.layout_auto (method), 46
igraph.Graph.layout_fruchterman_reingold_3d
(method), 71
igraph.Graph.layout_grid_3d (method),
71
igraph.Graph.layout_kamada_kawai_3d
(method), 71
igraph.Graph.layout_random_3d (method),
INDEX
INDEX
71
122
igraph.Graph.layout_sphere (method),
igraph.GraphBase.__getitem__ (method),
72
122
igraph.Graph.layout_sugiyama (method),
igraph.GraphBase.__invert__ (method),
47
122
igraph.Graph.maximum_bipartite_matching igraph.GraphBase.__or__ (method), 123
igraph.GraphBase.__rand__ (method),
(method), 48
igraph.Graph.omega (method), 13, 131
123
igraph.Graph.outdegree (method), 23
igraph.GraphBase.__ror__ (method),
igraph.Graph.pagerank (method), 32
123
igraph.Graph.Random_Bipartite (class
igraph.GraphBase.__setitem__ (method),
123
method), 63
igraph.Graph.Read (class method), 54,
igraph.GraphBase.add_edges (method),
55
123
igraph.Graph.Read_Adjacency (class method), igraph.GraphBase.add_vertices (method),
49
123
igraph.Graph.Read_GraphMLz (class method),igraph.GraphBase.Adjacency (method),
51
104
igraph.Graph.Read_Pickle (class method),
igraph.GraphBase.all_minimal_st_separators
(method), 123
52
igraph.Graph.Read_Picklez (class method), igraph.GraphBase.all_st_cuts (method),
53
124
igraph.Graph.shell_index (method), 13,
igraph.GraphBase.all_st_mincuts (method),
145
124
igraph.Graph.shortest_paths_dijkstra (method),
igraph.GraphBase.are_connected (method),
18, 197
124
igraph.Graph.spanning_tree (method),
igraph.GraphBase.assortativity (method),
33
125
igraph.Graph.subgraph (method), 19, 166
igraph.GraphBase.assortativity_degree
igraph.Graph.summary (method), 71
(method), 126
igraph.Graph.TupleList (class method),
igraph.GraphBase.assortativity_nominal
59
(method), 127
igraph.Graph.write (method), 56, 57
igraph.GraphBase.Asymmetric_Preference
igraph.Graph.write_adjacency (method),
(method), 104
49
igraph.GraphBase.Atlas (method), 105
igraph.Graph.write_graphmlz (method),
igraph.GraphBase.attributes (method),
50
127
igraph.Graph.write_pickle (method), 52
igraph.GraphBase.authority_score (method),
igraph.Graph.write_picklez (method), 52
127
igraph.Graph.write_svg (method), 53
igraph.GraphBase.average_path_length
igraph.GraphBase (class), 103215
(method), 128
igraph.GraphBase.__and__ (method),
igraph.GraphBase.Barabasi (method), 105
122
igraph.GraphBase.betweenness (method),
igraph.GraphBase.__delitem__ (method),
128
423
INDEX
INDEX
INDEX
INDEX
155
igraph.GraphBase.is_connected (method),
igraph.GraphBase.feedback_arc_set (method), 167
155
igraph.GraphBase.is_dag (method), 167
igraph.GraphBase.Forest_Fire (method),
igraph.GraphBase.is_directed (method),
109
167
igraph.GraphBase.Full (method), 110
igraph.GraphBase.is_loop (method), 167
igraph.GraphBase.Full_Citation (method),
igraph.GraphBase.is_minimal_separator
110
(method), 168
igraph.GraphBase.get_adjacency (method), igraph.GraphBase.is_multiple (method),
156
168
igraph.GraphBase.get_all_shortest_paths
igraph.GraphBase.is_mutual (method),
168
(method), 156
igraph.GraphBase.get_diameter (method),
igraph.GraphBase.is_separator (method),
157
169
igraph.GraphBase.get_edgelist (method),
igraph.GraphBase.is_simple (method),
157
169
igraph.GraphBase.get_eid (method), 157
igraph.GraphBase.Isoclass (method), 111
igraph.GraphBase.get_eids (method), 158
igraph.GraphBase.isoclass (method), 169
igraph.GraphBase.get_incidence (method),
igraph.GraphBase.isomorphic (method),
158
170
igraph.GraphBase.get_isomorphisms_vf2
igraph.GraphBase.isomorphic_bliss (method),
(method), 159
170
igraph.GraphBase.get_shortest_paths (method),
igraph.GraphBase.isomorphic_vf2 (method),
160
171
igraph.GraphBase.get_subisomorphisms_lad igraph.GraphBase.K_Regular (method),
(method), 161
111
igraph.GraphBase.get_subisomorphisms_vf2 igraph.GraphBase.Kautz (method), 111
(method), 162
igraph.GraphBase.knn (method), 172
igraph.GraphBase.girth (method), 163
igraph.GraphBase.laplacian (method), 173
igraph.GraphBase.gomory_hu_tree (method), igraph.GraphBase.largest_cliques (method),
164
173
igraph.GraphBase.Growing_Random (method),igraph.GraphBase.largest_independent_vertex_sets
110
(method), 174
igraph.GraphBase.has_multiple (method),
igraph.GraphBase.Lattice (method), 112
164
igraph.GraphBase.layout_bipartite (method),
igraph.GraphBase.hub_score (method),
174
164
igraph.GraphBase.layout_circle (method),
igraph.GraphBase.incident (method), 165
174
igraph.GraphBase.independent_vertex_sets igraph.GraphBase.layout_drl (method),
(method), 165
175
igraph.GraphBase.intersection (method),
igraph.GraphBase.layout_fruchterman_reingold
166
(method), 176
igraph.GraphBase.is_bipartite (method),
igraph.GraphBase.layout_graphopt (method),
166
177
425
INDEX
INDEX
igraph.GraphBase.layout_grid (method),
igraph.GraphBase.neighborhood_size (method),
178
193
igraph.GraphBase.layout_grid_fruchterman_reingold
igraph.GraphBase.neighbors (method),
(method), 179
193
igraph.GraphBase.layout_kamada_kawai
igraph.GraphBase.path_length_hist (method),
(method), 180
194
igraph.GraphBase.layout_lgl (method),
igraph.GraphBase.permute_vertices (method),
181
194
igraph.GraphBase.layout_mds (method),
igraph.GraphBase.personalized_pagerank
182
(method), 194
igraph.GraphBase.layout_random (method), igraph.GraphBase.predecessors (method),
183
195
igraph.GraphBase.layout_reingold_tilford
igraph.GraphBase.Preference (method),
112
(method), 183
igraph.GraphBase.layout_reingold_tilford_circular
igraph.GraphBase.radius (method), 196
(method), 184
igraph.GraphBase.Read_DIMACS (method),
igraph.GraphBase.layout_star (method),
113
185
igraph.GraphBase.Read_DL (method),
igraph.GraphBase.LCF (method), 112
113
igraph.GraphBase.linegraph (method), 185
igraph.GraphBase.Read_Edgelist (method),
igraph.GraphBase.maxdegree (method),
114
185
igraph.GraphBase.Read_GML (method),
igraph.GraphBase.maxflow (method), 186
114
igraph.GraphBase.maxflow_value (method), igraph.GraphBase.Read_GraphDB (method),
186
114
igraph.GraphBase.maximal_cliques (method), igraph.GraphBase.Read_GraphML (method),
187
114
igraph.GraphBase.maximal_independent_vertex_sets
igraph.GraphBase.Read_Lgl (method),
(method), 187
114
igraph.GraphBase.mincut (method), 187
igraph.GraphBase.Read_Ncol (method),
igraph.GraphBase.mincut_value (method),
115
188
igraph.GraphBase.Read_Pajek (method),
igraph.GraphBase.minimum_size_separators 116
igraph.GraphBase.Recent_Degree (method),
(method), 189
igraph.GraphBase.modularity (method),
116
189
igraph.GraphBase.reciprocity (method),
igraph.GraphBase.motifs_randesu (method),
196
190
igraph.GraphBase.rewire (method), 196
igraph.GraphBase.motifs_randesu_estimate igraph.GraphBase.rewire_edges (method),
(method), 191
197
igraph.GraphBase.motifs_randesu_no (method),
igraph.GraphBase.Ring (method), 117
192
igraph.GraphBase.SBM (method), 117
igraph.GraphBase.neighborhood (method),
igraph.GraphBase.similarity_dice (method),
192
198
426
INDEX
INDEX
igraph.GraphBase.similarity_inverse_log_weighted
igraph.GraphBase.Watts_Strogatz (method),
(method), 199
121
igraph.GraphBase.similarity_jaccard (method),igraph.GraphBase.Weighted_Adjacency
(method), 121
200
igraph.GraphBase.simplify (method), 201
igraph.GraphBase.write_dimacs (method),
igraph.GraphBase.st_mincut (method),
212
202
igraph.GraphBase.write_dot (method),
igraph.GraphBase.Star (method), 118
213
igraph.GraphBase.Static_Fitness (method), igraph.GraphBase.write_edgelist (method),
118
213
igraph.GraphBase.Static_Power_Law (method),
igraph.GraphBase.write_gml (method),
119
213
igraph.GraphBase.strength (method), 203
igraph.GraphBase.write_graphml (method),
igraph.GraphBase.subcomponent (method),
213
203
igraph.GraphBase.write_leda (method),
igraph.GraphBase.subgraph_edges (method),
214
204
igraph.GraphBase.write_lgl (method), 214
igraph.GraphBase.subisomorphic_lad (method),igraph.GraphBase.write_ncol (method),
204
214
igraph.GraphBase.subisomorphic_vf2 (method),igraph.GraphBase.write_pajek (method),
205
215
igraph.GraphBase.successors (method),
igraph.layout (module), 369375
206
igraph.layout.Layout (class), 369375
igraph.GraphBase.to_directed (method),
igraph.matching (module), 376379
207
igraph.matching.Matching (class), 376
igraph.GraphBase.to_undirected (method),
379
207
igraph.read (function), 4
igraph.GraphBase.topological_sorting (method),
igraph.remote (package), 380
207
igraph.remote.gephi (module), 381387
igraph.GraphBase.transitivity_avglocal_undirected
igraph.remote.nexus (module), 388392
(method), 207
igraph.statistics (module), 393403
igraph.GraphBase.transitivity_local_undirected
igraph.statistics.FittedPowerLaw (class),
(method), 208
396398
igraph.GraphBase.transitivity_undirected
igraph.statistics.Histogram (class), 398
(method), 209
400
igraph.GraphBase.Tree (method), 120
igraph.statistics.mean (function), 393
igraph.GraphBase.triad_census (method),
igraph.statistics.median (function), 393
210
igraph.statistics.percentile (function), 394
igraph.GraphBase.unfold_tree (method),
igraph.statistics.power_law_fit (function),
210
394
igraph.GraphBase.union (method), 211
igraph.statistics.quantile (function), 395
igraph.GraphBase.vcount (method), 211
igraph.statistics.RunningMean (class),
igraph.GraphBase.vertex_attributes (method), 400403
211
igraph.summary (function), 5
427
INDEX
INDEX
INDEX
INDEX
igraph.VertexSeq.subgraph (method), 92
igraph.write (function), 4
429