Note

This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.

Chains#

class Chains#

Bases: object

A custom class for the return of a list of list of edges.

The class is a read-only sequence of EdgeList instances.

This class is a container class for the results of functions that return a list of list of edges. It implements the Python sequence protocol. So you can treat the return as a read-only sequence/list that is integer indexed. If you want to use it as an iterator you can by wrapping it in an iter() that will yield the results in order.

For example:

import rustworkx as rx

graph = rx.generators.hexagonal_lattice_graph(2, 2)
chains = rx.chain_decomposition(graph)
# Index based access
third_chain = chains[2]
# Use as iterator
chains_iter = iter(chains)
first_chain = next(chains_iter)
second_chain = next(chains_iter)