rustworkx.PyDiGraph.remove_node_retain_edges#

PyDiGraph.remove_node_retain_edges(node, /, use_outgoing=None, condition=None)#

Remove a node from the graph and add edges from all predecessors to all successors

By default the data/weight on edges into the removed node will be used for the retained edges.

Parameters:
  • node (int) – The index of the node to remove. If the index is not present in the graph it will be ingored and this function willl have no effect.

  • use_outgoing (bool) – If set to true the weight/data from the edge outgoing from node will be used in the retained edge instead of the default weight/data from the incoming edge.

  • condition

    A callable that will be passed 2 edge weight/data objects, one from the incoming edge to node the other for the outgoing edge, and will return a bool on whether an edge should be retained. For example setting this kwarg to:

    lambda in_edge, out_edge: in_edge == out_edge
    

    would only retain edges if the input edge to node had the same data payload as the outgoing edge.