cfpq_data.graphs.utils.change_edges#

change_edges(graph: MultiDiGraph, mapping: Dict[Any, Any]) MultiDiGraph[source]#

Returns a graph with relabeled edges by specified edge labels mapping.

Parameters:
  • graph (MultiDiGraph) -- Initial graph.

  • mapping (Dict[Any, Any]) -- Edge labels mapping.

Examples

>>> from cfpq_data import *
>>> g = labeled_cycle_graph(2)
>>> list(g.edges(data=True))
[(0, 1, {'label': 'a'}), (1, 0, {'label': 'a'})]
>>> new_g = change_edges(g, {"a": "b"})
>>> list(new_g.edges(data=True))
[(0, 1, {'label': 'b'}), (1, 0, {'label': 'b'})]
Returns:

g -- A graph with changed edges.

Return type:

MultiDiGraph