3 ms·
This is interesting but I don't know Rust. Presumably your graph data structure grows dynamically, meaning you have to add nodes at runtime. When. you say you c
by tomcam 5y ago
This is interesting but I don't know Rust. Presumably your graph data structure grows dynamically, meaning you have to add nodes at runtime. When. you say you can't mutate the same data structure more than once at runtime, what does it mean? That you can't set both a parent and a child pointer in the same function, or what?
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- speedgoose 5y agoI’m very far from being a rust expert but it was difficult to build a bi-directional graph because it’s difficult to connect the nodes together. A simple recursive algorithm will not work. I ended up using a crate. I found the following article interesting on the topic : https://aminb.gitbooks.io/rust-for-c/content/graphs/ https://aminb.gitbooks.io/rust-for-c/content/graphs/
- jupp0r 5y agoIt shouldn't be difficult: 1. You have a graph struct that has ownership of all nodes (in Rc containers). 2. Nodes have Weak references to connected nodes
- bobbylarrybobby 5y agoIn the case of RefCell, when you begin modifying its data, you’re not allowed to begin modifying its data a second time without declaring “I’m done” with the first modification. This makes doing several modifications in different places that are interspersed with each other tricky because it’s hard to reason about when each spot is actually done so that a modification can be performed elsewhere. (If your program is single threaded it’s possible you don’t even care about mutation happening in multiple places, but Rust cares because in general Rust programs need not be single threaded.)
- throw10920 5y agoRust doesn't allow you to relax mutation constraints for a single-threaded program?