public static void DeleteVerticesAndMergeEdges <TVertex, TEdge>
     (this IMutableBidirectionalGraph <TVertex, TEdge> graph, IEnumerable <TVertex> vertexToDelete,
     Func <TEdge, TEdge, TEdge> mergeFunc)
     where TEdge : IEdge <TVertex>
 {
     foreach (var v in vertexToDelete)
     {
         graph.DeleteVerticesAndMergeEdges(v, mergeFunc);
     }
 }
        public static void DeleteVerticesAndMergeEdges <TVertex, TEdge>(
            this IMutableBidirectionalGraph <TVertex, TEdge> graph,
            Func <TVertex, bool> deletePredicate,
            Func <TEdge, TEdge, TEdge> mergeFunc,
            IEqualityComparer <TVertex> comparer = null)
            where TEdge : IEdge <TVertex>
        {
            var toDelete = graph.Vertices.Where(deletePredicate).ToList();

            foreach (var v in toDelete)
            {
                if (graph.Vertices.Contains(v, comparer))
                {
                    graph.DeleteVerticesAndMergeEdges(v, mergeFunc);
                }
            }
        }