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.


static PyGraph.read_edge_list(path, /, comment=None, deliminator=None, labels=False)#

Read an edge list file and create a new PyGraph object from the contents

The expected format for the edge list file is a line seperated list of deliminated node ids. If there are more than 3 elements on a line the 3rd on will be treated as a string weight for the edge

  • path (str) – The path of the file to open

  • comment (str) – Optional character to use as a comment by default there are no comment characters

  • deliminator (str) – Optional character to use as a deliminator by default any whitespace will be used

  • labels (bool) – If set to True the first two separated fields will be treated as string labels uniquely identifying a node instead of node indices.

For example:

import tempfile

import rustworkx as rx
from rustworkx.visualization import mpl_draw

with tempfile.NamedTemporaryFile('wt') as fd:
    path =
    fd.write('0 1\n')
    fd.write('0 2\n')
    fd.write('0 3\n')
    fd.write('1 2\n')
    fd.write('2 3\n')
    graph = rx.PyGraph.read_edge_list(path)