def shortest_path(dep, target): if hasattr(dep, "op"): dep = dep.op if hasattr(target, "op"): target = target.op return nx.shortest_path(nx_graph(), dep, target)