cfpq_data.graphs.utils.filter_edges#
- filter_edges(graph: MultiDiGraph, labels: Iterable[Any]) MultiDiGraph [source]#
Returns a graph with filtered edges.
- Parameters:
graph (MultiDiGraph) -- Initial graph.
labels (Iterable[Any]) -- Graph edge labels to be preserved.
Examples
>>> from cfpq_data import * >>> g = labeled_two_cycles_graph(1, 1, labels=("a", "b")) >>> list(g.edges(data=True)) [(1, 0, {'label': 'a'}), (0, 1, {'label': 'a'}), (0, 2, {'label': 'b'}), (2, 0, {'label': 'b'})] >>> new_g = filter_edges(g, ["a"]) >>> list(new_g.edges(data=True)) [(1, 0, {'label': 'a'}), (0, 1, {'label': 'a'})]
- Returns:
g -- Graph with filtered edges.
- Return type:
MultiDiGraph