
NetworkX Reference Release 2.0rc1.dev20170910155312 Aric Hagberg, Dan Schult, Pieter Swart Sep 10, 2017 Contents 1 Introduction 1 1.1 NetworkX Basics.............................................1 1.2 Graphs..................................................2 1.3 Graph Creation..............................................3 1.4 Graph Reporting.............................................3 1.5 Algorithms................................................4 1.6 Drawing.................................................4 1.7 Data Structure..............................................5 2 Graph types 7 2.1 Which graph class should I use?.....................................7 2.2 Basic graph types.............................................7 3 Algorithms 121 3.1 Approximation.............................................. 121 3.2 Assortativity............................................... 130 3.3 Bipartite................................................. 139 3.4 Boundary................................................. 168 3.5 Bridges.................................................. 169 3.6 Centrality................................................. 171 3.7 Chains.................................................. 196 3.8 Chordal.................................................. 196 3.9 Clique.................................................. 199 3.10 Clustering................................................ 203 3.11 Coloring................................................. 208 3.12 Communicability............................................. 211 3.13 Communities............................................... 213 3.14 Components............................................... 222 3.15 Connectivity............................................... 239 3.16 Cores................................................... 262 3.17 Covering................................................. 266 3.18 Cycles.................................................. 267 3.19 Cuts.................................................... 270 3.20 Directed Acyclic Graphs......................................... 274 3.21 Dispersion................................................ 279 3.22 Distance Measures............................................ 280 3.23 Distance-Regular Graphs......................................... 282 i 3.24 Dominance................................................ 284 3.25 Dominating Sets............................................. 286 3.26 Efficiency................................................. 287 3.27 Eulerian.................................................. 289 3.28 Flows................................................... 290 3.29 Graphical degree sequence........................................ 317 3.30 Hierarchy................................................. 321 3.31 Hybrid.................................................. 321 3.32 Isolates.................................................. 323 3.33 Isomorphism............................................... 324 3.34 Link Analysis............................................... 338 3.35 Link Prediction.............................................. 344 3.36 Matching................................................. 350 3.37 Minors.................................................. 352 3.38 Maximal independent set......................................... 358 3.39 Operators................................................. 359 3.40 Reciprocity................................................ 368 3.41 Rich Club................................................. 369 3.42 Shortest Paths.............................................. 370 3.43 Simple Paths............................................... 399 3.44 Structural holes.............................................. 402 3.45 Swap................................................... 405 3.46 Tournament................................................ 406 3.47 Traversal................................................. 409 3.48 Tree.................................................... 419 3.49 Triads................................................... 434 3.50 Vitality.................................................. 434 3.51 Voronoi cells............................................... 435 3.52 Wiener index............................................... 436 4 Functions 439 4.1 Graph................................................... 439 4.2 Nodes................................................... 442 4.3 Edges................................................... 443 4.4 Self loops................................................. 444 4.5 Attributes................................................. 446 4.6 Freezing graph structure......................................... 449 5 Graph generators 451 5.1 Atlas................................................... 451 5.2 Classic.................................................. 452 5.3 Expanders................................................ 459 5.4 Lattice.................................................. 460 5.5 Small................................................... 463 5.6 Random Graphs............................................. 467 5.7 Duplication Divergence......................................... 476 5.8 Degree Sequence............................................. 478 5.9 Random Clustered............................................ 484 5.10 Directed................................................. 485 5.11 Geometric................................................ 488 5.12 Line Graph................................................ 493 5.13 Ego Graph................................................ 494 5.14 Stochastic................................................. 495 5.15 Intersection................................................ 496 ii 5.16 Social Networks............................................. 497 5.17 Community................................................ 498 5.18 Trees................................................... 503 5.19 Non Isomorphic Trees.......................................... 504 5.20 Triads................................................... 505 5.21 Joint Degree Sequence.......................................... 505 6 Linear algebra 509 6.1 Graph Matrix............................................... 509 6.2 Laplacian Matrix............................................. 511 6.3 Spectrum................................................. 513 6.4 Algebraic Connectivity.......................................... 514 6.5 Attribute Matrices............................................ 517 7 Converting to and from other data formats 521 7.1 To NetworkX Graph........................................... 521 7.2 Dictionaries................................................ 522 7.3 Lists................................................... 523 7.4 Numpy.................................................. 524 7.5 Scipy................................................... 528 7.6 Pandas.................................................. 531 8 Relabeling nodes 535 8.1 Relabeling................................................ 535 9 Reading and writing graphs 539 9.1 Adjacency List.............................................. 539 9.2 Multiline Adjacency List......................................... 543 9.3 Edge List................................................. 546 9.4 GEXF................................................... 552 9.5 GML................................................... 554 9.6 Pickle................................................... 559 9.7 GraphML................................................. 561 9.8 JSON................................................... 563 9.9 LEDA................................................... 568 9.10 YAML.................................................. 569 9.11 SparseGraph6.............................................. 570 9.12 Pajek................................................... 576 9.13 GIS Shapefile............................................... 577 10 Drawing 579 10.1 Matplotlib................................................ 579 10.2 Graphviz AGraph (dot).......................................... 587 10.3 Graphviz with pydot........................................... 590 10.4 Graph Layout............................................... 592 11 Exceptions 597 11.1 Exceptions................................................ 597 12 Utilities 599 12.1 Helper Functions............................................. 599 12.2 Data Structures and Algorithms..................................... 601 12.3 Random Sequence Generators...................................... 601 12.4 Decorators................................................ 603 12.5 Cuthill-Mckee Ordering......................................... 603 iii 12.6 Context Managers............................................ 605 13 Glossary 607 A Tutorial 609 A.1 Creating a graph............................................. 609 A.2 Nodes................................................... 609 A.3 Edges................................................... 610 A.4 What to use as nodes and edges..................................... 611 A.5 Accessing edges and neighbors..................................... 612 A.6 Adding attributes to graphs, nodes, and edges.............................. 612 A.7 Directed graphs.............................................. 613 A.8 Multigraphs................................................ 614 A.9 Graph generators and graph operations................................. 614 A.10 Analyzing graphs............................................. 615 A.11 Drawing graphs............................................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages647 Page
-
File Size-