Recently, I've been trying to figure out a good way to model computation graphs in Rust. In this post, I explore using a graph with vector indices. I'm not sure if this is the best approach, but writing it out has helped me to understand the advantages and disadvantages better.
When I say "computation graph," I mean a representation of a mathematical expression like
2 * a + a * b. This example contains a constant (
2), two variables (
b), and two
functions (addition and multiplication). This expression can be modeled as a directed acyclic
In my ASCII diagram above, all edges go downwards. In general, edges don't really have any interesting information associated with them so I'm going to pretty much ignore them.