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