I have an idea for a project that hinges on this idea.
Lets say we have an adjacency matrix of a DiGraph where the i,j entry represents an out-going edge from node i to node j and at this position we have a rate describing how much of something leaves node i to node j in respect to time.
Is there a straight forward way using matrix algebra to convert this matrix to a system of ODEs that describes a multi-compartment model?
If you graph is represented by the adjacency matrix $A = \{a_{i,j}\}$, such that $a_{i,j} \geq 0$ for all $i \neq j$ and $a_{i,i} = 0$, then you can use the matrix:
$$B = \{b_{i,j}\}$$
where $b_{i,j} = a_{i,j}$ and $\displaystyle b_{j,j} = -\sum_{i=1,i\neq j}^{n} a_{i,j}$.
The ODE system is $\dot{x} = Bx$, where $$\dot{x}_i = \sum_{j=1}^n b_{i,j}x_j.$$
Notice that:
$$\sum_{i=1}^n\dot{x}_i = \sum_{i=1}^n\sum_{j=1}^n b_{i,j}x_j = \\ = \sum_{j=1}^nx_j\sum_{i=1}^n b_{i,j} = \sum_{j=1}^nx_j\left(b_{j,j} + \sum_{i=1, i \neq j}^n b_{i,j}\right) = \\ = \sum_{j=1}^nx_j\left(-\sum_{i=1,i\neq j}^{n} a_{i,j} + \sum_{i=1, i \neq j}^n a_{i,j}\right) = 0.$$
This means that the quantity $$\sum_{i=1}^n x_i$$ remains constant at every time since $$\sum_{i=1}^n\dot{x}_i = 0.$$