Networkx Reference Release 1.9.1

Networkx Reference Release 1.9.1

NetworkX Reference Release 1.9.1 Aric Hagberg, Dan Schult, Pieter Swart September 20, 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 Dominating Sets............................................. 237 4.19 Eulerian.................................................. 238 4.20 Flows................................................... 240 4.21 Graphical degree sequence........................................ 264 4.22 Hierarchy................................................. 268 4.23 Isolates.................................................. 269 4.24 Isomorphism............................................... 270 4.25 Link Analysis............................................... 283 i 4.26 Link Prediction.............................................. 290 4.27 Matching................................................. 296 4.28 Maximal independent set......................................... 298 4.29 Minimum Spanning Tree......................................... 299 4.30 Operators................................................. 300 4.31 Rich Club................................................. 308 4.32 Shortest Paths.............................................. 309 4.33 Simple Paths............................................... 327 4.34 Swap................................................... 328 4.35 Traversal................................................. 329 4.36 Tree.................................................... 336 4.37 Vitality.................................................. 338 5 Functions 339 5.1 Graph................................................... 339 5.2 Nodes................................................... 341 5.3 Edges................................................... 343 5.4 Attributes................................................. 344 5.5 Freezing graph structure......................................... 346 6 Graph generators 349 6.1 Atlas................................................... 349 6.2 Classic.................................................. 349 6.3 Small................................................... 354 6.4 Random Graphs............................................. 358 6.5 Degree Sequence............................................. 367 6.6 Random Clustered............................................ 373 6.7 Directed................................................. 374 6.8 Geometric................................................ 377 6.9 Hybrid.................................................. 381 6.10 Bipartite................................................. 381 6.11 Line Graph................................................ 385 6.12 Ego Graph................................................ 387 6.13 Stochastic................................................. 388 6.14 Intersection................................................ 388 6.15 Social Networks............................................. 390 7 Linear algebra 391 7.1 Graph Matrix............................................... 391 7.2 Laplacian Matrix............................................. 393 7.3 Spectrum................................................. 395 7.4 Algebraic Connectivity.......................................... 396 7.5 Attribute Matrices............................................ 399 8 Converting to and from other data formats 405 8.1 To NetworkX Graph........................................... 405 8.2 Dictionaries................................................ 406 8.3 Lists................................................... 407 8.4 Numpy.................................................. 408 8.5 Scipy................................................... 412 9 Reading and writing graphs 415 9.1 Adjacency List.............................................. 415 9.2 Multiline Adjacency List......................................... 419 9.3 Edge List................................................. 422 ii 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 473 12 Utilities 475 12.1 Helper Functions............................................. 475 12.2 Data Structures and Algorithms..................................... 476 12.3 Random Sequence Generators...................................... 476 12.4 Decorators................................................ 479 12.5 Cuthill-Mckee Ordering......................................... 480 12.6 Context Managers............................................ 482 13 License 485 14 Citing 487 15 Credits 489 16 Glossary 491 Bibliography 493 Python Module Index 503 Index 505 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.1 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

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    524 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us