
NetworkX Reference Release 1.11 Aric Hagberg, Dan Schult, Pieter Swart January 31, 2016 Contents 1 Overview 1 1.1 Who uses NetworkX?..........................................1 1.2 Goals...................................................1 1.3 The Python programming language...................................1 1.4 Free software...............................................2 1.5 History..................................................2 2 Introduction 3 2.1 NetworkX Basics.............................................3 2.2 Nodes and Edges.............................................4 3 Graph types 9 3.1 Which graph class should I use?.....................................9 3.2 Basic graph types.............................................9 4 Algorithms 131 4.1 Approximation.............................................. 131 4.2 Assortativity............................................... 141 4.3 Bipartite................................................. 149 4.4 Blockmodeling.............................................. 176 4.5 Boundary................................................. 177 4.6 Centrality................................................. 178 4.7 Chordal.................................................. 198 4.8 Clique.................................................. 201 4.9 Clustering................................................ 204 4.10 Coloring................................................. 207 4.11 Communities............................................... 209 4.12 Components............................................... 209 4.13 Connectivity............................................... 225 4.14 Cores................................................... 244 4.15 Cycles.................................................. 247 4.16 Directed Acyclic Graphs......................................... 250 4.17 Distance Measures............................................ 254 4.18 Distance-Regular Graphs......................................... 256 4.19 Dominance................................................ 258 4.20 Dominating Sets............................................. 260 4.21 Eulerian.................................................. 261 4.22 Flows................................................... 262 i 4.23 Graphical degree sequence........................................ 283 4.24 Hierarchy................................................. 286 4.25 Hybrid.................................................. 287 4.26 Isolates.................................................. 288 4.27 Isomorphism............................................... 289 4.28 Link Analysis............................................... 302 4.29 Link Prediction.............................................. 308 4.30 Matching................................................. 314 4.31 Minors.................................................. 315 4.32 Maximal independent set......................................... 319 4.33 Minimum Spanning Tree......................................... 320 4.34 Operators................................................. 322 4.35 Rich Club................................................. 331 4.36 Shortest Paths.............................................. 332 4.37 Simple Paths............................................... 350 4.38 Swap................................................... 352 4.39 Traversal................................................. 354 4.40 Tree.................................................... 361 4.41 Triads................................................... 366 4.42 Vitality.................................................. 367 5 Functions 369 5.1 Graph................................................... 369 5.2 Nodes................................................... 370 5.3 Edges................................................... 372 5.4 Attributes................................................. 373 5.5 Freezing graph structure......................................... 375 6 Graph generators 377 6.1 Atlas................................................... 377 6.2 Classic.................................................. 377 6.3 Expanders................................................ 382 6.4 Small................................................... 383 6.5 Random Graphs............................................. 387 6.6 Degree Sequence............................................. 395 6.7 Random Clustered............................................ 401 6.8 Directed................................................. 402 6.9 Geometric................................................ 405 6.10 Line Graph................................................ 408 6.11 Ego Graph................................................ 409 6.12 Stochastic................................................. 410 6.13 Intersection................................................ 411 6.14 Social Networks............................................. 412 6.15 Community................................................ 413 6.16 Non Isomorphic Trees.......................................... 417 7 Linear algebra 419 7.1 Graph Matrix............................................... 419 7.2 Laplacian Matrix............................................. 421 7.3 Spectrum................................................. 423 7.4 Algebraic Connectivity.......................................... 424 7.5 Attribute Matrices............................................ 427 8 Converting to and from other data formats 431 8.1 To NetworkX Graph........................................... 431 ii 8.2 Dictionaries................................................ 432 8.3 Lists................................................... 433 8.4 Numpy.................................................. 434 8.5 Scipy................................................... 438 8.6 Pandas.................................................. 440 9 Reading and writing graphs 443 9.1 Adjacency List.............................................. 443 9.2 Multiline Adjacency List......................................... 446 9.3 Edge List................................................. 450 9.4 GEXF................................................... 456 9.5 GML................................................... 458 9.6 Pickle................................................... 462 9.7 GraphML................................................. 463 9.8 JSON................................................... 465 9.9 LEDA................................................... 470 9.10 YAML.................................................. 471 9.11 SparseGraph6.............................................. 472 9.12 Pajek................................................... 477 9.13 GIS Shapefile............................................... 479 10 Drawing 481 10.1 Matplotlib................................................ 481 10.2 Graphviz AGraph (dot).......................................... 489 10.3 Graphviz with pydot........................................... 492 10.4 Graph Layout............................................... 494 11 Exceptions 499 11.1 Exceptions................................................ 499 12 Utilities 501 12.1 Helper Functions............................................. 501 12.2 Data Structures and Algorithms..................................... 502 12.3 Random Sequence Generators...................................... 502 12.4 Decorators................................................ 505 12.5 Cuthill-Mckee Ordering......................................... 506 12.6 Context Managers............................................ 508 13 License 509 14 Citing 511 15 Credits 513 15.1 Contributions............................................... 513 15.2 Support.................................................. 515 16 Glossary 517 Python Module Index 519 iii iv CHAPTER 1 Overview NetworkX is a Python language software package for the creation, manipulation, and study of the structure, dynamics, and function of complex networks. With NetworkX you can load and store networks in standard and nonstandard data formats, generate many types of random and classic networks, analyze network structure, build network models, design new network algorithms, draw networks, and much more. 1.1 Who uses NetworkX? The potential audience for NetworkX includes mathematicians, physicists, biologists, computer scientists, and social scientists. Good reviews of the state-of-the-art in the science of complex networks are presented in Albert and Barabási [BA02], Newman [Newman03], and Dorogovtsev and Mendes [DM03]. See also the classic texts [Bollobas01], [Diestel97] and [West01] for graph theoretic results and terminology. For basic graph algorithms, we recommend the texts of Sedgewick, e.g. [Sedgewick01] and [Sedgewick02] and the survey of Brandes and Erlebach [BE05]. 1.2 Goals NetworkX is intended to provide • tools for the study of the structure and dynamics of social, biological, and infrastructure networks, • a standard programming interface and graph implementation that is suitable for many applications, • a rapid development environment for collaborative, multidisciplinary projects, • an interface to existing numerical algorithms and code written in C, C++, and FORTRAN, • the ability to painlessly slurp in large nonstandard data sets. 1.3 The Python programming language Python is a powerful programming language that allows simple and flexible representations of networks, and clear and concise expressions of network algorithms (and other algorithms too). Python has a vibrant and
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages544 Page
-
File Size-