Utilities¶
Helper Functions¶
Miscellaneous Helpers for NetworkX.
These are not imported into the base networkx namespace but can be accessed, for example, as
>>> import networkx
>>> networkx.utils.is_string_like('spam')
True
|
Check if obj is string. |
|
Return flattened version of (possibly nested) iterable object. |
|
Return True if obj is iterable with a well-defined len(). |
|
Return True if list is a list of ints. |
|
Return list of ints from sequence of integral numbers. |
|
Returns the string representation of t. |
Generate a unique node label. |
|
|
Opens |
|
s -> (s0, s1), (s1, s2), (s2, s3), … |
|
Converts a many-to-one mapping into a one-to-many mapping. |
|
Returns a numpy.random.RandomState instance depending on input. |
Data Structures and Algorithms¶
Union-find data structure.
|
Find the sets containing the objects and merge them all. |
Random Sequence Generators¶
Utilities for generating random numbers, random sequences, and random selections.
|
Return sample sequence of length n from a power law distribution. |
|
Returns normalized cumulative distribution from discrete distribution. |
|
Return sample sequence of length n from a given discrete distribution or discrete cumulative distribution. |
|
Returns a random value chosen from the Zipf distribution. |
|
Returns k items without replacement from a weighted sample. |
|
Returns a single element from a weighted sample. |
Decorators¶
|
Decorator to ensure clean opening and closing of files. |
|
Decorator to mark algorithms as not implemented |
|
Decorator to allow number of nodes or container of nodes. |
|
Decorator to preserve the numpy.random state during a function. |
|
Decorator to generate a numpy.random.RandomState instance. |
Cuthill-Mckee Ordering¶
Cuthill-McKee ordering of graph nodes to produce sparse matrices
|
Generate an ordering (permutation) of the graph nodes to make a sparse matrix. |
|
Generate an ordering (permutation) of the graph nodes to make a sparse matrix. |