Note
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.
rustworkx.PyDiGraph.substitute_node_with_subgraph#
- PyDiGraph.substitute_node_with_subgraph(node, other, edge_map_fn, /, node_filter=None, edge_weight_map=None)#
Substitute a node with a PyDigraph object
- Parameters:
node (int) – The node to replace with the PyDiGraph object
other (PyDiGraph) – The other graph to replace
node
withedge_map_fn (callable) – A callable object that will take 3 position parameters,
(source, target, weight)
to represent an edge either to or fromnode
in this graph. The expected return value from this callable is the node index of the node inother
that an edge should be to/from. If None is returned, that edge will be skipped and not be copied.node_filter (callable) – An optional callable object that when used will receive a node’s payload object from
other
and returnTrue
if that node is to be included in the graph or not.edge_weight_map (callable) – An optional callable object that when used will receive an edge’s weight/data payload from
other
and will return an object to use as the weight for a newly created edge after the edge is mapped fromother
. If not specified the weight from the edge inother
will be copied by reference and used.
- Returns:
A mapping of node indices in
other
to the equivalent node in this graph.- Return type:
Note
The return type is a
rustworkx.NodeMap
which is an unordered type. So it does not provide a deterministic ordering between objects when iterated over (although the same object will have a consistent order when iterated over multiple times).