Implement isBetween for graph walking