[INPUT_SEPARATOR]
```
edit
file: solver.py
lines: 1-1
---

import numpy as np
import scipy.sparse
import scipy.sparse.csgraph
from typing import Dict, Any
import logging
from AlgoTuneTasks.base import register_task, Task


@register_task("graph_laplacian_solver")
class GraphLaplacianSolver(Task):
    def __init__(self, **kwargs):
        """
        Initializes the GraphLaplacianSolver task, which computes the Laplacian
        matrix of a graph represented in CSR format.
        """
        super().__init__(**kwargs)

    def solve(self, problem: Dict[str, Any]) -> Dict[str, Dict[str, Any]]:
        """
        Computes the graph Laplacian using scipy.sparse.csgraph.laplacian.

        The output Laplacian is returned in CSR format components.

        :param problem: A dictionary representing the graph (CSR) and `normed` flag.
        :return: A dictionary with key "laplacian" containing CSR components:
                    "data": List of non-zero Laplacian matrix entries.
                    "indices": List of column indices.
                    "indptr": List of index pointers.
                    "shape": Tuple (n, n).
                    Returns empty dict components on failure.
        """
        try:
            graph_csr = scipy.sparse.csr_matrix(
                (problem["data"], problem["indices"], problem["indptr"]), shape=problem["shape"]
            )
            normed = problem["normed"]
        except Exception as e:
            logging.error(f"Failed to reconstruct input CSR matrix: {e}")
            return {
                "laplacian": {
                    "data": [],
                    "indices": [],
                    "indptr": [],
                    "shape": problem.get("shape", (0, 0)),
                }
            }

        try:
            # Compute the Laplacian
            L = scipy.sparse.csgraph.laplacian(graph_csr, normed=normed)

            # Ensure output is CSR format
            if not isinstance(L, scipy.sparse.csr_matrix):
                L_csr = L.tocsr()
            else:
                L_csr = L
            L_csr.eliminate_zeros()  # Clean up

        except Exception as e:
            logging.error(f"scipy.sparse.csgraph.laplacian failed: {e}")
            return {
                "laplacian": {
                    "data": [],
                    "indices": [],
                    "indptr": [],
                    "shape": problem["shape"],
                }
            }

        return {
            "laplacian": {
                "data": L_csr.data.tolist(),
                "indices": L_csr.indices.tolist(),
                "indptr": L_csr.indptr.tolist(),
                "shape": L_csr.shape,
            }
        }
---
```
[INPUT_SEPARATOR]
```
edit
file: solver.py
lines: 1-1
---

import numpy as np
import scipy.sparse
import scipy.sparse.csgraph
from typing import Dict, Any
import logging
from AlgoTuneTasks.base import register_task, Task

class Solver():
    def __init__(self, **kwargs):
        """
        Initializes the GraphLaplacianSolver task, which computes the Laplacian
        matrix of a graph represented in CSR format.
        """

    def solve(self, problem: Dict[str, Any]) -> Dict[str, Dict[str, Any]]:
        """
        Computes the graph Laplacian using scipy.sparse.csgraph.laplacian.

        The output Laplacian is returned in CSR format components.

        :param problem: A dictionary representing the graph (CSR) and `normed` flag.
        :return: A dictionary with key "laplacian" containing CSR components:
                    "data": List of non-zero Laplacian matrix entries.
                    "indices": List of column indices.
                    "indptr": List of index pointers.
                    "shape": Tuple (n, n).
                    Returns empty dict components on failure.
        """
        try:
            graph_csr = scipy.sparse.csr_matrix(
                (problem["data"], problem["indices"], problem["indptr"]), shape=problem["shape"]
            )
            normed = problem["normed"]
        except Exception as e:
            logging.error(f"Failed to reconstruct input CSR matrix: {e}")
            return {
                "laplacian": {
                    "data": [],
                    "indices": [],
                    "indptr": [],
                    "shape": problem.get("shape", (0, 0)),
                }
            }

        try:
            # Compute the Laplacian
            L = scipy.sparse.csgraph.laplacian(graph_csr, normed=normed)

            # Ensure output is CSR format
            if not isinstance(L, scipy.sparse.csr_matrix):
                L_csr = L.tocsr()
            else:
                L_csr = L
            L_csr.eliminate_zeros()  # Clean up

        except Exception as e:
            logging.error(f"scipy.sparse.csgraph.laplacian failed: {e}")
            return {
                "laplacian": {
                    "data": [],
                    "indices": [],
                    "indptr": [],
                    "shape": problem["shape"],
                }
            }

        return {
            "laplacian": {
                "data": L_csr.data.tolist(),
                "indices": L_csr.indices.tolist(),
                "indptr": L_csr.indptr.tolist(),
                "shape": L_csr.shape,
            }
        }
---
```
[INPUT_SEPARATOR]
```
edit
file: solver.py
lines: 1-1
---

import numpy as np
import scipy.sparse
import scipy.sparse.csgraph
from typing import Dict, Any

class Solver():
    def __init__(self, **kwargs):
        """
        Initializes the GraphLaplacianSolver task, which computes the Laplacian
        matrix of a graph represented in CSR format.
        """

    def solve(self, problem: Dict[str, Any]) -> Dict[str, Dict[str, Any]]:
        """
        Computes the graph Laplacian using scipy.sparse.csgraph.laplacian.

        The output Laplacian is returned in CSR format components.

        :param problem: A dictionary representing the graph (CSR) and `normed` flag.
        :return: A dictionary with key "laplacian" containing CSR components:
                    "data": List of non-zero Laplacian matrix entries.
                    "indices": List of column indices.
                    "indptr": List of index pointers.
                    "shape": Tuple (n, n).
                    Returns empty dict components on failure.
        """
        try:
            graph_csr = scipy.sparse.csr_matrix(
                (problem["data"], problem["indices"], problem["indptr"]), shape=problem["shape"]
            )
            normed = problem["normed"]
        except Exception as e:
            logging.error(f"Failed to reconstruct input CSR matrix: {e}")
            return {
                "laplacian": {
                    "data": [],
                    "indices": [],
                    "indptr": [],
                    "shape": problem.get("shape", (0, 0)),
                }
            }

        try:
            # Compute the Laplacian
            L = scipy.sparse.csgraph.laplacian(graph_csr, normed=normed)

            # Ensure output is CSR format
            if not isinstance(L, scipy.sparse.csr_matrix):
                L_csr = L.tocsr()
            else:
                L_csr = L
            L_csr.eliminate_zeros()  # Clean up

        except Exception as e:
            logging.error(f"scipy.sparse.csgraph.laplacian failed: {e}")
            return {
                "laplacian": {
                    "data": [],
                    "indices": [],
                    "indptr": [],
                    "shape": problem["shape"],
                }
            }

        return {
            "laplacian": {
                "data": L_csr.data.tolist(),
                "indices": L_csr.indices.tolist(),
                "indptr": L_csr.indptr.tolist(),
                "shape": L_csr.shape,
            }
        }
---
```