(self, attribute=None)
return mtx
Returns the adjacency matrix of a graph as a SciPy CSR matrix.

        @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.
        @return: the adjacency matrix as a C{scipy.sparse.csr_matrix}.
Returns the adjacency matrix of a graph as a SciPy CSR matrix.
Returns the adjacency matrix of a graph as a SciPy CSR matrix .
def get_adjacency_sparse(self, attribute=None):
        """Returns the adjacency matrix of a graph as a SciPy CSR matrix.

        @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.
        @return: the adjacency matrix as a C{scipy.sparse.csr_matrix}.
        """
        try:
            from scipy import sparse
        except ImportError:
            raise ImportError(
                "You should install scipy in order to use this function"
            )

        edges = self.get_edgelist()
        if attribute is None:
            weights = [1] * len(edges)
        else:
            if attribute not in self.es.attribute_names():
                raise ValueError("Attribute does not exist")

            weights = self.es[attribute]

        N = self.vcount()
        mtx = sparse.csr_matrix((weights, list(zip(*edges))), shape=(N, N))

        if not self.is_directed():
            mtx = mtx + sparse.triu(mtx, 1).T + sparse.tril(mtx, -1).T
        return mtx
def get_adjacency_sparse ( self , attribute = None ) : try : from scipy import sparse except ImportError : raise ImportError ( "You should install scipy in order to use this function" ) edges = self . get_edgelist ( ) if attribute is None : weights = [ 1 ] * len ( edges ) else : if attribute not in self . es . attribute_names ( ) : raise ValueError ( "Attribute does not exist" ) weights = self . es [ attribute ] N = self . vcount ( ) mtx = sparse . csr_matrix ( ( weights , list ( zip ( * edges ) ) ) , shape = ( N , N ) ) if not self . is_directed ( ) : mtx = mtx + sparse . triu ( mtx , 1 ) . T + sparse . tril ( mtx , - 1 ) . T return mtx