helper function to check whether method a can reach method b in call graph