class WeightedEdgeList#

Bases: object

A custom class for the return of edge lists with weights

This class is a read-only sequence of tuples representing the edge endpoints with the data payload for that edge in the form:

[(node_index_a, node_index_b, weight)]

where node_index_a and node_index_b are the integer node indices of the edge endpoints and weight is the data payload of that edge.

This class is a container class for the results of functions that return a list of edges with weights. 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.directed_path_graph(5)
edges = graph.weighted_edge_list()
# Index based access
third_element = edges[2]
# Use as iterator
edges_iter = iter(edges)
first_element = next(edges_iter)
second_element = next(edges_iter)