cutcutcodec.core.edit.operation.remove.remove_edges

cutcutcodec.core.edit.operation.remove.remove_edges(graph: MultiDiGraph, edges: Iterable[tuple[str, str, str]]) dict[tuple[str, str, str], None | tuple[str, str, str]][source]

Delete several edges from the graph.

Parameters

graphnetwork.MultiDiGraph

The assembly graph containing the edges to be deleted. The operations on this graph will be performed in-place.

edgestyping.Iterable[tuple[str, str, str]]

The name of the edges 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 one of the edges 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_edges
>>> 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_edges(
...     graph,
...     [
...         ('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', '1->1'): None,
 ('container_input_ffmpeg_1', 'container_output_1', '2->2'): None,
 ('container_input_ffmpeg_1', 'container_output_1', '3->3'): ('container_input_ffmpeg_1',
                                                              'container_output_1',
                                                              '3->1')}
>>> pprint(list(graph.edges))
[('container_input_ffmpeg_1', 'container_output_1', '0->0'),
 ('container_input_ffmpeg_1', 'container_output_1', '3->1')]
>>>