Hello. I'm trying to use petgraph to create a graph with a large number of vertices. I'm currently trying with 1684212 and it says this -
thread 'main' panicked at 'assertion failed: node_capacity <= <Ix as IndexType>::max().index()', /home/cocoa/.cargo/registry/src/index.crates.io-6f17d22bba15001f/petgraph-0.6.3/src/matrix_graph.rs:238:9
stack backtrace:
0: rust_begin_unwind
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
1: core::panicking::panic_fmt
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
2: core::panicking::panic
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:117:5
3: petgraph::matrix_graph::MatrixGraph<N,E,Ty,Null,Ix>::with_capacity
at /home/cocoa/.cargo/registry/src/index.crates.io-6f17d22bba15001f/petgraph-0.6.3/src/matrix_graph.rs:238:9
4: mwe::main
at ./src/main.rs:4:17
5: core::ops::function::FnOnce::call_once
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
I'm using a MatrixGraph because I need a graph type where I can add and remove vertices and edges and CSR graphs didn't have that. I want to use u64
or usize
to store the number of vertices. Here is a minimal working example of my issue -
use petgraph::matrix_graph::MatrixGraph;
fn main() {
let grpah = MatrixGraph::<i64, f64>::with_capacity(1684212);
}