(
        self, type=GET_ADJACENCY_BOTH, attribute=None, default=0, eids=False
    )
return Matrix(data)
Returns the adjacency matrix of a graph.

        @param type: either C{GET_ADJACENCY_LOWER} (uses the lower
          triangle of the matrix) or C{GET_ADJACENCY_UPPER}
          (uses the upper triangle) or C{GET_ADJACENCY_BOTH}
          (uses both parts). Ignored for directed graphs.
        @param attribute: if C{None}, returns the ordinary adjacency
          matrix. When the name of a valid edge attribute is given
          here, the matrix returned will contain the default value
          at the places where there is no edge or the value of the
          given attribute where there is an edge. Multiple edges are
          not supported, the value written in the matrix in this case
          will be unpredictable. This parameter is ignored if
          I{eids} is C{True}
        @param default: the default value written to the cells in the
          case of adjacency matrices with attributes.
        @param eids: specifies whether the edge IDs should be returned
          in the adjacency matrix. Since zero is a valid edge ID, the
          cells in the matrix that correspond to unconnected vertex
          pairs will contain -1 instead of 0 if I{eids} is C{True}.
          If I{eids} is C{False}, the number of edges will be returned
          in the matrix for each vertex pair.
        @return: the adjacency matrix as a L{Matrix}.
Returns the adjacency matrix of a graph.
Returns the adjacency matrix of a graph .
def get_adjacency(
        self, type=GET_ADJACENCY_BOTH, attribute=None, default=0, eids=False
    ):
        """Returns the adjacency matrix of a graph.

        @param type: either C{GET_ADJACENCY_LOWER} (uses the lower
          triangle of the matrix) or C{GET_ADJACENCY_UPPER}
          (uses the upper triangle) or C{GET_ADJACENCY_BOTH}
          (uses both parts). Ignored for directed graphs.
        @param attribute: if C{None}, returns the ordinary adjacency
          matrix. When the name of a valid edge attribute is given
          here, the matrix returned will contain the default value
          at the places where there is no edge or the value of the
          given attribute where there is an edge. Multiple edges are
          not supported, the value written in the matrix in this case
          will be unpredictable. This parameter is ignored if
          I{eids} is C{True}
        @param default: the default value written to the cells in the
          case of adjacency matrices with attributes.
        @param eids: specifies whether the edge IDs should be returned
          in the adjacency matrix. Since zero is a valid edge ID, the
          cells in the matrix that correspond to unconnected vertex
          pairs will contain -1 instead of 0 if I{eids} is C{True}.
          If I{eids} is C{False}, the number of edges will be returned
          in the matrix for each vertex pair.
        @return: the adjacency matrix as a L{Matrix}.
        """
        if (
            type != GET_ADJACENCY_LOWER
            and type != GET_ADJACENCY_UPPER
            and type != GET_ADJACENCY_BOTH
        ):
            # Maybe it was called with the first argument as the attribute name
            type, attribute = attribute, type
            if type is None:
                type = GET_ADJACENCY_BOTH

        if eids:
            result = Matrix(GraphBase.get_adjacency(self, type, eids))
            result -= 1
            return result

        if attribute is None:
            return Matrix(GraphBase.get_adjacency(self, type))

        if attribute not in self.es.attribute_names():
            raise ValueError("Attribute does not exist")

        data = [[default] * self.vcount() for _ in range(self.vcount())]

        if self.is_directed():
            for edge in self.es:
                data[edge.source][edge.target] = edge[attribute]
            return Matrix(data)

        if type == GET_ADJACENCY_BOTH:
            for edge in self.es:
                source, target = edge.tuple
                data[source][target] = edge[attribute]
                data[target][source] = edge[attribute]
        elif type == GET_ADJACENCY_UPPER:
            for edge in self.es:
                data[min(edge.tuple)][max(edge.tuple)] = edge[attribute]
        else:
            for edge in self.es:
                data[max(edge.tuple)][min(edge.tuple)] = edge[attribute]

        return Matrix(data)
def get_adjacency ( self , type = GET_ADJACENCY_BOTH , attribute = None , default = 0 , eids = False ) : if ( type != GET_ADJACENCY_LOWER and type != GET_ADJACENCY_UPPER and type != GET_ADJACENCY_BOTH ) : # Maybe it was called with the first argument as the attribute name type , attribute = attribute , type if type is None : type = GET_ADJACENCY_BOTH if eids : result = Matrix ( GraphBase . get_adjacency ( self , type , eids ) ) result -= 1 return result if attribute is None : return Matrix ( GraphBase . get_adjacency ( self , type ) ) if attribute not in self . es . attribute_names ( ) : raise ValueError ( "Attribute does not exist" ) data = [ [ default ] * self . vcount ( ) for _ in range ( self . vcount ( ) ) ] if self . is_directed ( ) : for edge in self . es : data [ edge . source ] [ edge . target ] = edge [ attribute ] return Matrix ( data ) if type == GET_ADJACENCY_BOTH : for edge in self . es : source , target = edge . tuple data [ source ] [ target ] = edge [ attribute ] data [ target ] [ source ] = edge [ attribute ] elif type == GET_ADJACENCY_UPPER : for edge in self . es : data [ min ( edge . tuple ) ] [ max ( edge . tuple ) ] = edge [ attribute ] else : for edge in self . es : data [ max ( edge . tuple ) ] [ min ( edge . tuple ) ] = edge [ attribute ] return Matrix ( data )