Sum weighted nodes between nodes in a DAG efficiently Suppose we have a directed acyclic graph $G=(V,E)$, such that all vertices have a addible weight, e.g. there is a function $weight: V \to \mathbb{R} $. Moreover two vertices $v,w \in V$ are given and we write $G_{v,w}$ for the subgraph of $G$ that consists of all vertices and path between $v$ and $w$, both included. 

The task is to compute the sum of the weight $weight(u)$ of all vertices $u \in G_{v,w}$. 
In addition if $v'$ and $w'$ are two vertices, with $G_{v,w}\subset G_{v',w'}$, then the computation on $G_{v,w}$ should not be repeated (kind of divide and conquer, but on subgraphs) to compute the weight of $G_{v',w'}$.

Is that possible?
A vertex $z$ is "between $v$ and $w$" in $G$ (that is there is a path in $G$ from $v$ to $w$ that traverses $z$) if and only if both the following conditions are true: 1) there is a path from $v$ to $z$ in $G$; and 2) there is a path from $w$ to $z$ in $\overline{G}$, where  $\overline{G}$ is the graph obtained from $G$ by reversing its edges.

Using any standard visit algorithm you can compute the set $A$ of vertices reachable from $v$ in $G$ and the set $B$ of vertices reachable from $w$ in $\overline{G}$. 

Then you can compute $C = A \cap B$ and find the desired quantity as $\sum_{z \in C} \text{weight}(z)$. Each of the above steps can be performed in linear time.