{"url":"/method/ct-layer","slug":"ct-layer","name":"CT-Layer","full_name":"Commute Times Layer","full_name_withheld":false,"description_markdown":"**TL;DR: CT-Layer is a GNN Layer which is able to rewire a graph in an inductive an parameter-free way according to the commute times distance (or effective resistance). We address it learning a differentiable way to compute the CT-embedding of the graph.**\r\n\r\n### Summary\r\n\r\n**CT-Layer** is able to Learn the *Commute Times distance*  between nodes (i.e. *effective resistance distance*) in a **differentiable** way, instead of the common spectral version, and in a **parameter free** manner, which is not the cased of the heat kernel. This approach allow to solve it as an optimization problem inside a GNN, leading to have a new layer which is able to learn how rewire a given graph in an optimal, and **inductive** way. \r\n\r\nIn addition, **CT-Layer** also is able to learn *Commute Times embeddings*, and then calculate it for any graph in an inductive way. The Commute Times embedding is also related with the *eigenvalues* and *eigenvectors* of the Laplacian of the graph, because CT embedding is just the eigenvectors scaled. Therefore, CT-Layer is also able to learn hot to calculate the spectrum of the Laplacian in a differentiable way. Therefore, this embedding must satisfy orthogonality and normality.\r\n\r\nFinally, recent connections has been found between commute times distance and **curvature** (which is non-differentiable), establishing equivalences between them. Therefore, **CT-Layer** can also be seen as the differentiable version of the curvature rewiring.\r\n\r\n**We are going through a quick overview of the layer, but I suggest go to the paper for a detailed explanation. **\r\n\r\n### Spectral CT- Embedding downsides\r\nCT-embedding $\\mathbf{Z}$ is computed spectrally  in the literature (until the proposal of this method) or it is approximated using the heat kernel (very dependent on hyperparameter $t$). This fact does not allow us to propose differentiable methods using that measure:\r\n$$\r\n\\mathbf{Z}=\\sqrt{vol(G)}\\mathbf{\\Lambda}^\\frac{1}{2}\\mathbf{F}^T \\textrm{ given } \\mathbf{L}=\\mathbf{F}\\mathbf{\\Lambda}\\mathbf{F}^T\r\n$$\r\n\r\nThen, CT-distance  is given by the Euclidean distances between the embeddings $CT_{uv} = ||\\mathbf{z_u}-\\mathbf{z_v}||^2$. The spectral form is: \r\n\r\n$$\r\n\\frac{CT_{uv}}{vol(G)} = \\sum_{i=2}^n \\frac{1}{\\lambda_i} (\\mathbf{f}(u)-\\mathbf{f}(v))^2 \r\n$$\r\nbeing $\\mathbf{f}$ the eigenvectors of the graph Laplacian. \r\n\r\nThis embedding and distances gives us desirable properties of the graph, such an understanding of the structure, or an embedding based on the spectrum which minimizes Dirichlet energies. However, **the spectral computation is not differentiable**.\r\n\r\n### CT-Layer as an optimization problem: Differentiable, learnable and inductive CT-Layer\r\nGiving that $\\mathbf{Z}$ minimizes Dirichlet energies s.t. being orthogonal and normalized, we can formulate this problem as constraining neighboring nodes to have a similar embeddings s.t. $\\mathbf{Z}\\mathbf{Z}^T=\\mathbf{I}$.\r\n\r\n$$\r\n\\mathbf{Z} = \\arg\\min_{\\mathbf{Z}^T\\mathbf{Z}=\\mathbf{I}} \\frac{\\sum\\_{u,v} ||\\mathbf{z_u}-\\mathbf{z_v}||^2\\mathbf{A}\\_{uv}}{\\sum\\_{u,v} \\mathbf{Z}^2\\_{uv} d_u}=\\frac{Tr[\\mathbf{Z}^T\\mathbf{L}\\mathbf{Z}]}{Tr[\\mathbf{Z}^T\\mathbf{D}\\mathbf{Z}]}\r\n$$\r\n\r\nWith the above elements we have a definition of **CT-Layer**, our rewiring layer: \r\nGiven the matrix $\\mathbf{X}\\_{n\\times F}$ encoding the features of the nodes after any message passing (MP) layer, $\\mathbf{Z}\\_{n\\times O(n)}=\\tanh(\\textrm{MLP}(\\mathbf{X}))$ learns the association $\\mathbf{X}\\rightarrow \\mathbf{Z}$ while $\\mathbf{Z}$ is optimized according to the loss \r\n$$\r\nL\\_{CT} = \\frac{Tr[\\mathbf{Z}^T\\mathbf{L}\\mathbf{Z}]}{Tr[\\mathbf{Z}^T\\mathbf{D}\\mathbf{Z}]} + \\left\\|\\frac{\\mathbf{Z}^T\\mathbf{Z}}{\\|\\mathbf{Z}^T\\mathbf{Z}\\|\\_F} - \\mathbf{I}\\_n\\right\\|\\_F\r\n$$\r\n This results in the following **resistance diffusion** $\\mathbf{T}^{CT} = \\mathbf{R}(\\mathbf{S})\\odot \\mathbf{A}$ (Hadamard product between the resistance distance and the adjacency) which provides as input to the subsequent MP layer a learnt convolution matrix.\r\n\r\nAs explained before, $\\mathbf{Z}$ is the **commute times embedding matrix** and the pairwise euclidian distance of that learned embeddings are the **commute times distances** or resistance distances. **Therefore, once trained this layer, it will be able to calculate the commute times embedding for a new graph, and rewire that new and unseen graph in a principled way based on the commute times distance.**\r\n\r\n## Preservation of Structure\r\nDoes this rewiring preserve the original structure? Let $G' = \\textrm{Sparsify}(G, q)$ be a sampling algorithm of graph $G = (V, E)$, where edges $e \\in E$ are sampled with probability $q\\propto R_e$ (**proportional to the effective resistance, i.e. commute times**).\r\nThen, for $n = |V|$ sufficiently large and $1/\\sqrt{n}< \\epsilon\\le 1$, we need O(n\\log n/\\epsilon^2)$ samples to satisfy:\r\n\r\n$$\r\n\\forall \\mathbf{x}\\in\\mathbb{R}^n:\\; (1-\\epsilon)\\mathbf{x}^T\\mathbf{L}\\_G\\mathbf{x}\\le\\mathbf{x}^T\\mathbf{L}\\_{G'}\\mathbf{x}\\le (1+\\epsilon)\\mathbf{x}^T\\mathbf{L}\\_G\\mathbf{x}\r\n$$\r\n\r\nThe intuitions behind is that Dirichlet energies in $G'$ are bounded in $(1\\pm \\epsilon)$ of the Dirichlet energies of the original graph $G$.","description_state":"present","introduced_year":null,"introduced_by":{"title":"DiffWire: Inductive Graph Rewiring via the Lovász Bound","paper":"/paper/diffwire-inductive-graph-rewiring-via-the","first_author":"Adrian Arnaiz-Rodriguez","n_authors":4,"url_abs":null,"archive_paper_url":"https://paperswithcode.com/paper/diffwire-inductive-graph-rewiring-via-the"},"source":{"url":"https://arxiv.org/abs/2206.07369v3","title":"DiffWire: Inductive Graph Rewiring via the Lovász Bound","url_on_a_paper_host":true},"code_snippet_url":"https://anonymous.4open.science/r/DiffWireNeurIPS22/CT_layer.py","code_snippet_url_on_a_code_host":true,"categories":[{"area":"Graphs","area_id":"graphs","collection":"Graph Models","url":"/methods/category/graph-models","pwc_aliases":[]},{"area":"Graphs","area_id":"graphs","collection":"Graph Embeddings","url":"/methods/category/graph-embeddings","pwc_aliases":[]}],"n_papers_tagged":1,"archive_num_papers":1,"papers_newest_first":[{"paper":"/paper/diffwire-inductive-graph-rewiring-via-the","title":"DiffWire: Inductive Graph Rewiring via the Lovász Bound","date":"2022-06-15","arxiv_id":"2206.07369","n_code_links":2,"syntology":null}],"papers_shown":1,"tasks":[{"task":"/task/graph-classification","name":"Graph Classification","papers":1},{"task":"/task/node-classification","name":"Node Classification","papers":1}],"tasks_shown":2,"n_tasks":2,"usage_by_year":[{"year":"2022","papers":1}],"row_source":"methods_table","archive":{"source":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","archive_url":"https://paperswithcode.com/method/ct-layer"},"syntology_read_at":"2026-09-24T18:15:14+00:00"}