@@ -259,6 +259,59 @@ where
259
259
self . graph . edge_count ( )
260
260
}
261
261
262
+ /// Reserves capacity for at least `additional` more nodes to be inserted in
263
+ /// the graph. Graph may reserve more space to avoid frequent reallocations.
264
+ ///
265
+ /// **Panics** if the new capacity overflows `usize`.
266
+ pub fn reserve_nodes ( & mut self , additional : usize ) {
267
+ self . graph . reserve_nodes ( additional)
268
+ }
269
+
270
+ /// Reserves the minimum capacity for exactly `additional` more nodes to be
271
+ /// inserted in the graph. Does nothing if the capacity is already
272
+ /// sufficient.
273
+ ///
274
+ /// Prefer `reserve_nodes` if future insertions are expected.
275
+ ///
276
+ /// **Panics** if the new capacity overflows `usize`.
277
+ pub fn reserve_exact_nodes ( & mut self , additional : usize ) {
278
+ self . graph . reserve_exact_nodes ( additional)
279
+ }
280
+
281
+ /// Reserves capacity for at least `additional` more edges to be inserted in
282
+ /// the graph. Graph may reserve more space to avoid frequent reallocations.
283
+ ///
284
+ /// **Panics** if the new capacity overflows `usize`.
285
+ pub fn reserve_edges ( & mut self , additional : usize ) {
286
+ self . graph . reserve_edges ( additional)
287
+ }
288
+
289
+ /// Reserves the minimum capacity for exactly `additional` more edges to be
290
+ /// inserted in the graph.
291
+ /// Does nothing if the capacity is already sufficient.
292
+ ///
293
+ /// Prefer `reserve_edges` if future insertions are expected.
294
+ ///
295
+ /// **Panics** if the new capacity overflows `usize`.
296
+ pub fn reserve_exact_edges ( & mut self , additional : usize ) {
297
+ self . graph . reserve_exact_edges ( additional)
298
+ }
299
+
300
+ /// Shrinks the capacity of the graph as much as possible.
301
+ pub fn shrink_to_fit ( & mut self ) {
302
+ self . graph . shrink_to_fit ( ) ;
303
+ }
304
+
305
+ /// Shrinks the capacity of the underlying nodes collection as much as possible.
306
+ pub fn shrink_to_fit_nodes ( & mut self ) {
307
+ self . graph . shrink_to_fit_nodes ( ) ;
308
+ }
309
+
310
+ /// Shrinks the capacity of the underlying edges collection as much as possible.
311
+ pub fn shrink_to_fit_edges ( & mut self ) {
312
+ self . graph . shrink_to_fit_edges ( ) ;
313
+ }
314
+
262
315
/// Borrow the `Dag`'s underlying `DiGraph<N, Ix>`.
263
316
///
264
317
/// All existing indices may be used to index into this `DiGraph` the same way they may be
0 commit comments