networkx.utils

Functions

accumulate(iterable[, func])
arbitrary_element(iterable) Returns an arbitrary element of iterable without removing it.
consume(iterator) Consume the iterator entirely.
create_degree_sequence(n[, sfunction, max_tries])
cumulative_distribution(distribution) Return normalized cumulative distribution from discrete distribution.
cuthill_mckee_ordering(G[, heuristic]) Generate an ordering (permutation) of the graph nodes to make a sparse matrix.
default_opener(filename) Opens filename using system’s default program.
dict_to_numpy_array(d[, mapping]) Convert a dictionary of dictionaries to a numpy array with optional mapping.
dict_to_numpy_array1(d[, mapping]) Convert a dictionary of numbers to a 1d numpy array with optional mapping.
dict_to_numpy_array2(d[, mapping]) Convert a dictionary of dictionaries to a 2d numpy array with optional mapping.
discrete_sequence(n[, distribution, ...]) Return sample sequence of length n from a given discrete distribution or discrete cumulative distribution.
flatten(obj[, result]) Return flattened version of (possibly nested) iterable object.
generate_unique_node() Generate a unique node label.
groups(many_to_one) Converts a many-to-one mapping into a one-to-many mapping.
is_iterator(obj) Returns True if and only if the given object is an iterator object.
is_list_of_ints(intlist) Return True if list is a list of ints.
is_string_like(obj) Check if obj is string.
iterable(obj) Return True if obj is iterable with a well-defined len().
make_str(x) Return the string representation of t.
nodes_or_number(which_args) Decorator to allow number of nodes or container of nodes.
not_implemented_for(*graph_types) Decorator to mark algorithms as not implemented
open_file(path_arg[, mode]) Decorator to ensure clean opening and closing of files.
pairwise(iterable[, cyclic]) s -> (s0, s1), (s1, s2), (s2, s3), ...
pareto_sequence(n[, exponent]) Return sample sequence of length n from a Pareto distribution.
powerlaw_sequence(n[, exponent]) Return sample sequence of length n from a power law distribution.
random_weighted_sample(mapping, k) Return k items without replacement from a weighted sample.
reverse_cuthill_mckee_ordering(G[, heuristic]) Generate an ordering (permutation) of the graph nodes to make a sparse matrix.
reversed(*args, **kwds) A context manager for temporarily reversing a directed graph in place.
tee tee(iterable, n=2) –> tuple of n independent iterators.
to_tuple(x) Converts lists to tuples.
uniform_sequence(n) Return sample sequence of length n from a uniform distribution.
weighted_choice(mapping) Return a single element from a weighted sample.
zipf_rv(alpha[, xmin, seed]) Return a random value chosen from the Zipf distribution.
zipf_sequence(n[, alpha, xmin]) Return a sample sequence of length n from a Zipf distribution with exponent parameter alpha and minimum value xmin.

Classes

BinaryHeap() A binary heap.
MinHeap() Base class for min-heaps.
PairingHeap() A pairing heap.
UnionFind([elements]) Union-find data structure.
chain chain(*iterables) –> chain object
defaultdict defaultdict(default_factory[, ...]) –> dict with default factory
deque deque([iterable[, maxlen]]) –> deque object
groupby (key, sub-iterator) grouped by each value of key(value).