rustworkx.PyDiGraph.add_edge#

PyDiGraph.add_edge(parent, child, edge, /)#

在2个节点之间添加一条边。

使用add_child()或add_parent()可在创建节点的同时创建边以提高性能。当multigraph属性设置为True时,此方法允许在节点间添加重复边。

Parameters:
  • parent (int) – 父节点的索引

  • child (int) – 子节点的索引

  • edge (T) – 要附加至边的Python对象。

Returns:

新创建边的索引

Return type:

整数

Raises:

PyIndexError: When the new edge would create a cycle