rustworkx.PyDAG.remove_node_retain_edges#
- PyDAG.remove_node_retain_edges(node, /, use_outgoing=False, 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.
This function has a minimum time complexity of \(\mathcal O(e_i e_o)\), where \(e_i\) and \(e_o\) are the numbers of incoming and outgoing edges respectively. If your
conditioncan be cast as an equality between two hashable quantities, consider usingremove_node_retain_edges_by_key()instead, or if yourconditionis referential object identity of the edge weights, considerremove_node_retain_edges_by_id().- Parameters:
node (int) – The index of the node to remove. If the index is not present in the graph it will be ignored and this function will have no effect.
use_outgoing (bool) – If set to
Truethe weight/data from the edge outgoing fromnodewill be used in the retained edge instead of the default weight/data from the incoming edge.condition (Callable) –
A callable that will be passed 2 edge weight/data objects, one from the incoming edge to
nodethe other for the outgoing edge, and will return aboolon 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
nodehad the same data payload as the outgoing edge.