(graph, cfg_slice_to_sink)
return graph
Slice a CFG graph, keeping only the transitions and nodes present in the <CFGSliceToSink> representation.

    *Note* that this function mutates the graph passed as an argument.

    :param networkx.DiGraph graph: The graph to slice.
    :param CFGSliceToSink cfg_slice_to_sink:
        The representation of the slice, containing the data to update the CFG from.

    :return networkx.DiGraph: The sliced graph.
Slice a CFG graph, keeping only the transitions and nodes present in the <CFGSliceToSink> representation.
Slice a CFG graph keeping only the transitions and nodes present in the <CFGSliceToSink > representation .
def slice_cfg_graph(graph, cfg_slice_to_sink):
    """
    Slice a CFG graph, keeping only the transitions and nodes present in the <CFGSliceToSink> representation.

    *Note* that this function mutates the graph passed as an argument.

    :param networkx.DiGraph graph: The graph to slice.
    :param CFGSliceToSink cfg_slice_to_sink:
        The representation of the slice, containing the data to update the CFG from.

    :return networkx.DiGraph: The sliced graph.
    """

    def _edge_in_slice_transitions(transitions, edge):
        if edge[0].addr not in transitions.keys():
            return False
        return edge[1].addr in cfg_slice_to_sink.transitions[edge[0].addr]

    edges_to_remove = list(filter(
        lambda edge: not _edge_in_slice_transitions(cfg_slice_to_sink.transitions, edge),
        graph.edges()
    ))

    nodes_to_remove = list(filter(
        lambda node: node.addr not in cfg_slice_to_sink.nodes,
        graph.nodes()
    ))

    graph.remove_edges_from(edges_to_remove)
    graph.remove_nodes_from(nodes_to_remove)

    return graph
def slice_cfg_graph ( graph , cfg_slice_to_sink ) : def _edge_in_slice_transitions ( transitions , edge ) : if edge [ 0 ] . addr not in transitions . keys ( ) : return False return edge [ 1 ] . addr in cfg_slice_to_sink . transitions [ edge [ 0 ] . addr ] edges_to_remove = list ( filter ( lambda edge : not _edge_in_slice_transitions ( cfg_slice_to_sink . transitions , edge ) , graph . edges ( ) ) ) nodes_to_remove = list ( filter ( lambda node : node . addr not in cfg_slice_to_sink . nodes , graph . nodes ( ) ) ) graph . remove_edges_from ( edges_to_remove ) graph . remove_nodes_from ( nodes_to_remove ) return graph