I am attempting to implement an algorithm found in a paper. One of the subtasks is: "given a directed acyclic graph $(V,E)$, subset of edges $E' \in E$, and vertices $u,v \in V$, find all edges $e \in E''\subset E'$ that lie on some simple path composed of of edges in $E'$ from $u$ to $v$". That is to say, find all edges that lie on some simple path from $u$ to $v$ in the induced graph $(V,E')$.
The best I was able to come up with is:
Create induced graph $(V,E')$. For every edge $e \in E'$, search for an endpoint $q$ of $e$ using BFS from root node $u$. If found, search for $v$ with BFS from root node $q$. If both succeed, add $e$ to $E''$.
I suspect there a more efficient way to do it but the paper claims it can be done in $O(|E|)$ . In addition, I would like to be able to do this with existing libraries or methods (I'm currently using networkx with python).