(self, *args, **kwds)
Returns the first vertex of the vertex sequence that matches some
        criteria.

        The selection criteria are equal to the ones allowed by L{VertexSeq.select}.
        See L{VertexSeq.select} for more details.

        For instance, to find the first vertex with name C{foo} in graph C{g}:

            >>> g.vs.find(name="foo")            #doctest:+SKIP

        To find an arbitrary isolated vertex:

            >>> g.vs.find(_degree=0)             #doctest:+SKIP
Returns the first vertex of the vertex sequence that matches some
        criteria.
Returns the first vertex of the vertex sequence that matches some criteria .
def find(self, *args, **kwds):
        """Returns the first vertex of the vertex sequence that matches some
        criteria.

        The selection criteria are equal to the ones allowed by L{VertexSeq.select}.
        See L{VertexSeq.select} for more details.

        For instance, to find the first vertex with name C{foo} in graph C{g}:

            >>> g.vs.find(name="foo")            #doctest:+SKIP

        To find an arbitrary isolated vertex:

            >>> g.vs.find(_degree=0)             #doctest:+SKIP
        """
        # Shortcut: if "name" is in kwds, there are no positional arguments,
        # and the specified name is a string, we try that first because that
        # attribute is indexed. Note that we cannot do this if name is an
        # integer, because it would then translate to g.vs.select(name), which
        # searches by _index_ if the argument is an integer
        if not args:
            if "name" in kwds:
                name = kwds.pop("name")
            elif "name_eq" in kwds:
                name = kwds.pop("name_eq")
            else:
                name = None

            if name is not None:
                if isinstance(name, str):
                    args = [name]
                else:
                    # put back what we popped
                    kwds["name"] = name

        if args:
            # Selecting first based on positional arguments, then checking
            # the criteria specified by the (remaining) keyword arguments
            vertex = _VertexSeq.find(self, *args)
            if not kwds:
                return vertex
            vs = self.graph.vs.select(vertex.index)
        else:
            vs = self

        # Selecting based on keyword arguments
        vs = vs.select(**kwds)
        if vs:
            return vs[0]
        raise ValueError("no such vertex")
def find ( self , * args , * * kwds ) : # Shortcut: if "name" is in kwds, there are no positional arguments, # and the specified name is a string, we try that first because that # attribute is indexed. Note that we cannot do this if name is an # integer, because it would then translate to g.vs.select(name), which # searches by _index_ if the argument is an integer if not args : if "name" in kwds : name = kwds . pop ( "name" ) elif "name_eq" in kwds : name = kwds . pop ( "name_eq" ) else : name = None if name is not None : if isinstance ( name , str ) : args = [ name ] else : # put back what we popped kwds [ "name" ] = name if args : # Selecting first based on positional arguments, then checking # the criteria specified by the (remaining) keyword arguments vertex = _VertexSeq . find ( self , * args ) if not kwds : return vertex vs = self . graph . vs . select ( vertex . index ) else : vs = self # Selecting based on keyword arguments vs = vs . select ( * * kwds ) if vs : return vs [ 0 ] raise ValueError ( "no such vertex" )