/** * Resize the graph to make room for additional vertices and edges. * * The method doubles the size of the Vertices array and Adjacency matrix * and copies the existing vertex and edge data to the newly allocated * memory. */ private void Resize() { int new_max_vertex_count = 2 * Vertices.Length; VertexT[] new_vertices = new VertexT[new_max_vertex_count]; // Copy the existing vertices to the new array Vertices.CopyTo(new_vertices, 0); // Resize the adjacency matrix. This call will take care of moving // the existing edge data to the new location. Edges.Resize(new_max_vertex_count, Size); Vertices = new_vertices; }