<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_igraph(self, attribute="weight", **kwargs):
 """Convert to an igraph Graph Uses the igraph.Graph.Weighted_Adjacency constructor Parameters attribute : str, optional (default: "weight") kwargs : additional arguments for igraph.Graph.Weighted_Adjacency """

        try:
            import igraph as ig
        except ImportError:
            raise ImportError("Please install igraph with "
                              "`pip install --user python-igraph`.")
        try:
            W = self.W
        except AttributeError:
            # not a pygsp graph
            W = self.K.copy()
            W = utils.set_diagonal(W, 0)
        return ig.Graph.Weighted_Adjacency(utils.to_dense(W).tolist(),
                                           attr=attribute, **kwargs)