`dasp_graph` incompatible with latest version of `petgraph`
dasp_graph is incompatible with the latest version (0.6.x) of petgraph. When using the two together you get the error that petgraph::visit::Visitable is not implemented for petgraph::Graph when trying to instantiate a dasp_graph::Processor.
EDIT: I can replicate it, it's just that cargo does not like dev-dependencies to be a different version than a dependency, so I had to alias the dev-dependency like so: petgraph_dev = { package = "petgraph", version = "0.6", features = ["stable_graph",] }.
This is expected behavior for how rust handles multiple instances of the same dependency with different versions. Any version skew means the two are treated as entirely separate crates, so even though they have items with the same name, they are considered distinct types due to the nominal type system. In fact, Rust now tells you this in the error message:
two types coming from two different versions of the same crate are different types even if they look the same
~~I cannot replicate this. dasp_graph uses pegraph 0.5.x internally, and I've tested this with petgraph 0.6.x and 0.8.x and have no issue.~~
~~What I did to replicate it:~~
- ~~set petgraph dev-dependency to 0.6 or 0.8 on dasp_graph, while keeping internal dependency to 0.6~~
- ~~wrote a basic function that instantiates a graph, a processor and a dummy node, running the processor. No issues with compiling or at runtime.~~
~~Cargo.toml snippet:~~
[dependencies]
# ...
petgraph = { version = "0.5", default-features = false }
[dev-dependencies]
petgraph = { version = "0.6", features = ["stable_graph"] }
~~Rust example snippet:~~
use dasp_graph::{Buffer, Node, NodeData};
struct SimpleNode;
impl Node for SimpleNode {
fn process(&mut self, _inputs: &[dasp_graph::Input], output: &mut [dasp_graph::Buffer]) {
output[0].fill(1.23);
}
}
#[test]
fn issue_176() {
let mut processor = dasp_graph::Processor::with_capacity(1);
let mut graph = petgraph::Graph::<NodeData<SimpleNode>, (), petgraph::Directed, u32>::new();
let node = graph.add_node(NodeData::new(SimpleNode, vec![Buffer::from([0.0; 64])]));
processor.process(&mut graph, node);
assert!(graph.node_weight(node).unwrap().buffers[0]
.iter()
.all(|x| *x == 1.23));
}
Regardless, maybe we should update petgraph to the latest version and re-export petgraph as part of the API to ensure version alignment?