(
        cls,
        matrix,
        directed=False,
        mode="out",
        multiple=False,
        weighted=None,
        *args,
        **kwds
    )
return result
Creates a bipartite graph from an incidence matrix.

        Example:

        >>> g = Graph.Incidence([[0, 1, 1], [1, 1, 0]])

        @param matrix: the incidence matrix.
        @param directed: whether to create a directed graph.
        @param mode: defines the direction of edges in the graph. If
          C{"out"}, then edges go from vertices of the first kind
          (corresponding to rows of the matrix) to vertices of the
          second kind (the columns of the matrix). If C{"in"}, the
          opposite direction is used. C{"all"} creates mutual edges.
          Ignored for undirected graphs.
        @param multiple: defines what to do with non-zero entries in the
          matrix. If C{False}, non-zero entries will create an edge no matter
          what the value is. If C{True}, non-zero entries are rounded up to
          the nearest integer and this will be the number of multiple edges
          created.
        @param weighted: defines whether to create a weighted graph from the
          incidence matrix. If it is c{None} then an unweighted graph is created
          and the multiple argument is used to determine the edges of the graph.
          If it is a string then for every non-zero matrix entry, an edge is created
          and the value of the entry is added as an edge attribute named by the
          weighted argument. If it is C{True} then a weighted graph is created and
          the name of the edge attribute will be ‘weight’.

        @raise ValueError: if the weighted and multiple are passed together.

        @return: the graph with a binary vertex attribute named C{"type"} that
          stores the vertex classes.
Creates a bipartite graph from an incidence matrix.
Creates a bipartite graph from an incidence matrix .
def Incidence(
        cls,
        matrix,
        directed=False,
        mode="out",
        multiple=False,
        weighted=None,
        *args,
        **kwds
    ):
        """Creates a bipartite graph from an incidence matrix.

        Example:

        >>> g = Graph.Incidence([[0, 1, 1], [1, 1, 0]])

        @param matrix: the incidence matrix.
        @param directed: whether to create a directed graph.
        @param mode: defines the direction of edges in the graph. If
          C{"out"}, then edges go from vertices of the first kind
          (corresponding to rows of the matrix) to vertices of the
          second kind (the columns of the matrix). If C{"in"}, the
          opposite direction is used. C{"all"} creates mutual edges.
          Ignored for undirected graphs.
        @param multiple: defines what to do with non-zero entries in the
          matrix. If C{False}, non-zero entries will create an edge no matter
          what the value is. If C{True}, non-zero entries are rounded up to
          the nearest integer and this will be the number of multiple edges
          created.
        @param weighted: defines whether to create a weighted graph from the
          incidence matrix. If it is c{None} then an unweighted graph is created
          and the multiple argument is used to determine the edges of the graph.
          If it is a string then for every non-zero matrix entry, an edge is created
          and the value of the entry is added as an edge attribute named by the
          weighted argument. If it is C{True} then a weighted graph is created and
          the name of the edge attribute will be ‘weight’.

        @raise ValueError: if the weighted and multiple are passed together.

        @return: the graph with a binary vertex attribute named C{"type"} that
          stores the vertex classes.
        """
        is_weighted = True if weighted or weighted == "" else False
        if is_weighted and multiple:
            raise ValueError("arguments weighted and multiple can not co-exist")
        result, types = cls._Incidence(matrix, directed, mode, multiple, *args, **kwds)
        result.vs["type"] = types
        if is_weighted:
            weight_attr = "weight" if weighted is True else weighted
            _, rows, _ = result.get_incidence()
            num_vertices_of_first_kind = len(rows)
            for edge in result.es:
                source, target = edge.tuple
                if source in rows:
                    edge[weight_attr] = matrix[source][
                        target - num_vertices_of_first_kind
                    ]
                else:
                    edge[weight_attr] = matrix[target][
                        source - num_vertices_of_first_kind
                    ]
        return result
def Incidence ( cls , matrix , directed = False , mode = "out" , multiple = False , weighted = None , * args , * * kwds ) : is_weighted = True if weighted or weighted == "" else False if is_weighted and multiple : raise ValueError ( "arguments weighted and multiple can not co-exist" ) result , types = cls . _Incidence ( matrix , directed , mode , multiple , * args , * * kwds ) result . vs [ "type" ] = types if is_weighted : weight_attr = "weight" if weighted is True else weighted _ , rows , _ = result . get_incidence ( ) num_vertices_of_first_kind = len ( rows ) for edge in result . es : source , target = edge . tuple if source in rows : edge [ weight_attr ] = matrix [ source ] [ target - num_vertices_of_first_kind ] else : edge [ weight_attr ] = matrix [ target ] [ source - num_vertices_of_first_kind ] return result