cutcutcodec.core.edit.operation.remove.remove_edge
- cutcutcodec.core.edit.operation.remove.remove_edge(graph: MultiDiGraph, edge: tuple[str, str, str]) dict[tuple[str, str, str], None | tuple[str, str, str]][source]
Delete an edge from the graph.
Parameters
- graphnetwork.MultiDiGraph
The assembly graph containing the edge to be deleted. The operations on this graph will be performed in-place.
- edgetuple[str, str, str]
The name of the edge to delete from the graph (src_node, dst_node, key).
Returns
- edgesdict
Each old edge name is associated with its new name. If the new name is None, it means that the edge has been deleted. This allows to be informed of all the operations performed.
Raises
- KeyError
If the edge is not in the graph.
Examples
>>> from pprint import pprint >>> from cutcutcodec.core.classes.container import ContainerOutput >>> from cutcutcodec.core.compilation.tree_to_graph import tree_to_graph >>> from cutcutcodec.core.edit.operation.remove import remove_edge >>> from cutcutcodec.core.io.read_ffmpeg import ContainerInputFFMPEG >>> with ContainerInputFFMPEG("cutcutcodec/examples/intro.webm") as container: ... tree = ContainerOutput(container.out_streams) ... >>> graph = tree_to_graph(tree) >>> pprint(list(graph.edges)) [('container_input_ffmpeg_1', 'container_output_1', '0->0'), ('container_input_ffmpeg_1', 'container_output_1', '1->1'), ('container_input_ffmpeg_1', 'container_output_1', '2->2'), ('container_input_ffmpeg_1', 'container_output_1', '3->3')] >>> pprint(remove_edge(graph, ('container_input_ffmpeg_1', 'container_output_1', '1->1'))) {('container_input_ffmpeg_1', 'container_output_1', '1->1'): None, ('container_input_ffmpeg_1', 'container_output_1', '2->2'): ('container_input_ffmpeg_1', 'container_output_1', '2->1'), ('container_input_ffmpeg_1', 'container_output_1', '3->3'): ('container_input_ffmpeg_1', 'container_output_1', '3->2')} >>> pprint(list(graph.edges)) [('container_input_ffmpeg_1', 'container_output_1', '0->0'), ('container_input_ffmpeg_1', 'container_output_1', '2->1'), ('container_input_ffmpeg_1', 'container_output_1', '3->2')] >>>