find the subgraph between two nodes in a directed acyclic graph