
NetworkX Reference Release 1.9 Aric Hagberg, Dan Schult, Pieter Swart June 21, 2014 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 127 4.1 Approximation.............................................. 127 4.2 Assortativity............................................... 132 4.3 Bipartite................................................. 141 4.4 Blockmodeling.............................................. 161 4.5 Boundary................................................. 162 4.6 Centrality................................................. 163 4.7 Chordal.................................................. 184 4.8 Clique.................................................. 187 4.9 Clustering................................................ 190 4.10 Communities............................................... 193 4.11 Components............................................... 194 4.12 Connectivity............................................... 208 4.13 Cores................................................... 225 4.14 Cycles.................................................. 229 4.15 Directed Acyclic Graphs......................................... 231 4.16 Distance Measures............................................ 234 4.17 Distance-Regular Graphs......................................... 236 4.18 Eulerian.................................................. 237 4.19 Flows................................................... 239 4.20 Graphical degree sequence........................................ 263 4.21 Hierarchy................................................. 267 4.22 Isolates.................................................. 268 4.23 Isomorphism............................................... 269 i 4.24 Link Analysis............................................... 282 4.25 Link Prediction.............................................. 289 4.26 Matching................................................. 296 4.27 Maximal independent set......................................... 297 4.28 Minimum Spanning Tree......................................... 298 4.29 Operators................................................. 299 4.30 Rich Club................................................. 307 4.31 Shortest Paths.............................................. 308 4.32 Simple Paths............................................... 326 4.33 Swap................................................... 327 4.34 Traversal................................................. 328 4.35 Tree.................................................... 335 4.36 Vitality.................................................. 337 5 Functions 339 5.1 Graph................................................... 339 5.2 Nodes................................................... 341 5.3 Edges................................................... 342 5.4 Attributes................................................. 343 5.5 Freezing graph structure......................................... 345 6 Graph generators 347 6.1 Atlas................................................... 347 6.2 Classic.................................................. 347 6.3 Small................................................... 352 6.4 Random Graphs............................................. 356 6.5 Degree Sequence............................................. 365 6.6 Random Clustered............................................ 371 6.7 Directed................................................. 372 6.8 Geometric................................................ 375 6.9 Hybrid.................................................. 379 6.10 Bipartite................................................. 379 6.11 Line Graph................................................ 383 6.12 Ego Graph................................................ 385 6.13 Stochastic................................................. 386 6.14 Intersection................................................ 386 6.15 Social Networks............................................. 388 7 Linear algebra 389 7.1 Graph Matrix............................................... 389 7.2 Laplacian Matrix............................................. 391 7.3 Spectrum................................................. 393 7.4 Algebraic Connectivity.......................................... 394 7.5 Attribute Matrices............................................ 397 8 Converting to and from other data formats 403 8.1 To NetworkX Graph........................................... 403 8.2 Dictionaries................................................ 404 8.3 Lists................................................... 405 8.4 Numpy.................................................. 406 8.5 Scipy................................................... 411 9 Reading and writing graphs 415 9.1 Adjacency List.............................................. 415 9.2 Multiline Adjacency List......................................... 419 ii 9.3 Edge List................................................. 422 9.4 GEXF................................................... 429 9.5 GML................................................... 431 9.6 Pickle................................................... 434 9.7 GraphML................................................. 435 9.8 JSON................................................... 437 9.9 LEDA................................................... 442 9.10 YAML.................................................. 443 9.11 SparseGraph6.............................................. 444 9.12 Pajek................................................... 450 9.13 GIS Shapefile............................................... 452 10 Drawing 455 10.1 Matplotlib................................................ 455 10.2 Graphviz AGraph (dot).......................................... 464 10.3 Graphviz with pydot........................................... 467 10.4 Graph Layout............................................... 469 11 Exceptions 475 12 Utilities 477 12.1 Helper Functions............................................. 477 12.2 Data Structures and Algorithms..................................... 478 12.3 Random Sequence Generators...................................... 478 12.4 Decorators................................................ 481 12.5 Cuthill-Mckee Ordering......................................... 482 12.6 Context Managers............................................ 484 13 License 487 14 Citing 489 15 Credits 491 16 Glossary 493 Bibliography 495 Python Module Index 505 Index 507 iii iv CHAPTER ONE 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 growing ecosystem of packages that NetworkX uses to provide more features such as numerical linear algebra and drawing. In addition Python is also an excellent “glue” language for putting together pieces of software from other languages which allows reuse of legacy code and engineering of high-performance algorithms [Langtangen04]. Equally important, Python is free, well-supported, and a joy to use. 1 NetworkX Reference, Release 1.9 In order to make the most out of NetworkX you will want to know how to write basic programs in Python. Among the many guides to Python, we recommend the documentation at http://www.python.org and the text by Alex Martelli [Martelli03]. 1.4 Free software NetworkX is free software; you
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages526 Page
-
File Size-