public int RemoveVertexIf(VertexPredicate <TVertex> predicate)
        {
            var vertices = new VertexList <TVertex>();

            foreach (var v in Vertices)
            {
                if (predicate(v))
                {
                    vertices.Add(v);
                }
            }

            foreach (var v in vertices)
            {
                RemoveVertex(v);
            }
            return(vertices.Count);
        }
        public void MergeVertexIf(VertexPredicate <TVertex> vertexPredicate, EdgeFactory <TVertex, TEdge> edgeFactory)
        {
            Contract.Requires(vertexPredicate != null);
            Contract.Requires(edgeFactory != null);

            // storing vertices to merge
            var mergeVertices = new VertexList <TVertex>(VertexCount / 4);

            foreach (var v in Vertices)
            {
                if (vertexPredicate(v))
                {
                    mergeVertices.Add(v);
                }
            }

            // applying merge recursively
            foreach (var v in mergeVertices)
            {
                MergeVertex(v, edgeFactory);
            }
        }
예제 #3
0
 public VertexList(VertexList <TVertex> other)
     : base(other)
 {
 }