def has_path(G, source, target):
    try:
        sp = nx.shortest_path(G, source, target)
    except nx.NetworkXNoPath:
        return False
    return True
Return *True* if *G* has a path from *source* to *target*.
dataset/ETHPy150Open networkx/networkx/networkx/algorithms/shortest_paths/generic.py/has_path