/// <summary>
        /// Remove edges from the graph
        /// </summary>
        /// <param name="input"></param>
        /// <param name="keep"></param>
        /// <returns></returns>
        [NotNull] public static IMutableControlFlowGraph Trim([NotNull] this IControlFlowGraph input, [NotNull] Func <IEdge, bool> keep)
        {
            var cfg = new ControlFlowGraph();

            var replacementVertices = input.CloneVertices(cfg, __ => true);
            var _ = input.CloneEdges(cfg, replacementVertices, keep);

            return(cfg);
        }
        /// <summary>
        /// Remove vertices from the graph
        /// </summary>
        /// <param name="input"></param>
        /// <param name="keep"></param>
        /// <returns></returns>
        [NotNull] public static IMutableControlFlowGraph Trim([NotNull] this IControlFlowGraph input, [NotNull] Func <IBasicBlock, bool> keep)
        {
            var cfg = new ControlFlowGraph();

            var rv = input.CloneVertices(cfg, keep);
            var _  = input.CloneEdges(cfg, rv, a => rv.ContainsKey(a.Start) && rv.ContainsKey(a.End));

            return(cfg);
        }
        /// <summary>
        /// Copy graph and modify vertices
        /// </summary>
        /// <param name="input"></param>
        /// <param name="copy"></param>
        /// <returns></returns>
        [NotNull] public static IMutableControlFlowGraph Modify([NotNull] this IControlFlowGraph input, [NotNull] Action <IBasicBlock, IMutableBasicBlock> copy)
        {
            var cfg = new ControlFlowGraph();

            // Copy vertices (but leave empty)
            var replacementVertices = input.CloneVertices(cfg, __ => true, (___, ____) => { });

            // Copy edges
            var _ = input.CloneEdges(cfg, replacementVertices, __ => true);

            // Apply clone function to vertices
            foreach (var(key, value) in replacementVertices)
            {
                copy(key, value);
            }

            return(cfg);
        }
        [NotNull] public static IMutableControlFlowGraph Modify([NotNull] this IControlFlowGraph input, [NotNull] Action <IEdge, Action <IBasicBlock, IBasicBlock, EdgeType> > copy)
        {
            var cfg = new ControlFlowGraph();

            // Copy vertices
            var replacementVertices = input.CloneVertices(cfg, __ => true);

            // Copy edges
            foreach (var edge in input.Edges)
            {
                copy(edge, (s, e, t) => {
                    var ss = replacementVertices[s];
                    var ee = replacementVertices[e];
                    cfg.CreateEdge(ss, ee, t);
                });
            }

            return(cfg);
        }