

def has_edge(self, u, v, key=None):
    "Return True if the graph has an edge between nodes u and v.\n\n        Parameters\n        ----------\n        u,v : nodes\n            Nodes can be, for example, strings or numbers.\n\n        key : hashable identifier, optional (default=None)\n            If specified return True only if the edge with\n            key is found.\n\n        Returns\n        -------\n        edge_ind : bool\n            True if edge is in the graph, False otherwise.\n\n        Examples\n        --------\n        Can be called either using two nodes u,v, an edge tuple (u,v),\n        or an edge tuple (u,v,key).\n\n        >>> G = nx.MultiGraph()   # or MultiDiGraph\n        >>> G.add_path([0,1,2,3])\n        >>> G.has_edge(0,1)  # using two nodes\n        True\n        >>> e = (0,1)\n        >>> G.has_edge(*e)  #  e is a 2-tuple (u,v)\n        True\n        >>> G.add_edge(0,1,key='a')\n        >>> G.has_edge(0,1,key='a')  # specify key\n        True\n        >>> e=(0,1,'a')\n        >>> G.has_edge(*e) # e is a 3-tuple (u,v,'a')\n        True\n\n        The following syntax are equivalent:\n\n        >>> G.has_edge(0,1)\n        True\n        >>> 1 in G[0]  # though this gives KeyError if 0 not in G\n        True\n\n\n\n        "
    try:
        if (key is None):
            return (v in self.adj[u])
        else:
            return (key in self.adj[u][v])
    except KeyError:
        return False

dataset/ETHPy150Open networkx/networkx/networkx/classes/tests/timingclasses.py TimingMultiGraph.has_edge/original