def _path_exists(graph, source, target): try: path = networkx.shortest_path(graph, source, target) except NetworkXException: path = [] return bool(path)