# Calculus on finite weighted graphs

In mathematics, calculus on finite weighted graphs is a discrete calculus for functions whose domain is the vertex set of a graph with a finite number of vertices and weights associated to the edges. This involves formulating discrete operators on graphs which are analogous to differential operators in calculus, such as graph Laplacians (or discrete Laplace operators) as discrete versions of the Laplacian, and using these operators to formulate differential equations, difference equations, or variational models on graphs which can be interpreted as discrete versions of partial differential equations or continuum variational models. Such equations and models are important tools to mathematically model, analyze, and process discrete information in many different research fields, e.g., image processing, machine learning, and network analysis.
In applications, finite weighted graphs represent a finite number of entities by the graph's vertices, any pairwise relationships between these entities by graph edges, and the significance of a relationship by an edge weight function. Differential equations or difference equations on such graphs can be employed to leverage the graph's structure for tasks such as image segmentation (where the vertices represent pixels and the weighted edges encode pixel similarity based on comparisons of Moore neighborhoods or larger windows), data clustering, data classification, or community detection in a social network (where the vertices represent users of the network, the edges represent links between users, and the weight function indicates the strength of interactions between users).
The main advantage of finite weighted graphs is that by not being restricted to highly regular structures such as discrete regular grids, lattice graphs, or meshes, they can be applied to represent abstract data with irregular interrelationships.
If a finite weighted graph is geometrically embedded in a Euclidean space, i.e., the graph vertices represent points of this space, then it can be interpreted as a discrete approximation of a related nonlocal operator in the continuum setting.

## Basic definitions

A finite weighted graph $G$ is defined as a triple $G=(V,E,w)$ for which
* $V=\{x_{1},\dots ,x_{n}\},n\in \mathbb {N}$, is a finite set of indices denoted as graph vertices or nodes,
* $E\subset V\times V$ is a finite set of (directed) graph edges connecting a subset of vertices,
* $w\colon E\rightarrow \mathbb {R}$ is an edge weight function defined on the edges of the graph.
In a directed graph, each edge $(x_{i},x_{j})\in E$ has a start node $x_{i}\in V$ and an end node $x_{j}\in V$. In an undirected graph for every edge $(x_{i},x_{j})$ there exists an edge $(x_{j},x_{i})$ and the weight function is required to be symmetric, i.e., $w(x_{i},x_{j})=w(x_{j},x_{i})$. On the remainder of this page, the graphs will be assumed to be undirected, unless specifically stated otherwise. Many of the ideas presented on this page can be generalized to directed graphs.
The edge weight function $w$ associates to every edge $(x_{i},x_{j})\in E$ a real value $w(x_{i},x_{j})>0$. For both mathematical and application specific reasons, the weight function on the edges is often required to be strictly positive and on this page it will be assumed to be so unless specifically stated otherwise. Generalizations of many of the ideas presented on this page to include negatively weighted edges are possible. Sometimes an extension of the domain of the edge weight function to $V\times V$ is considered (with the resulting function still being called the edge weight function) by setting $w(x_{i},x_{j})=0$ whenever $(x_{i},x_{j})\not \in E$.
In applications each graph vertex $x\in V$ usually represents a single entity in the given data, e.g., elements of a finite data set, pixels in an image, or users in a social network. A graph edge represents a relationship between two entities, e.g. pairwise interactions or similarity based on comparisons of geometric neighborhoods (for example of pixels in images) or of another feature, with the edge weight encoding the strength of this relationship. Most commonly used weight functions are normalized to map to values between 0 and 1, i.e., $w:E\rightarrow (0,1]$.
In the following it is assumed that the considered graphs are connected without self-loops or multiple edges between vertices. These assumptions are mostly harmless as in many applications each connected component of a disconnected graph can be treated as a graph in its own right, each appearance of $w(x_{i},x_{i})$ (which would be nonzero in the presence of self-loops) appears in the presence of another factor which disappears when $i=j$ (see the section on differential graph operators below), and edge weights can encode similar information as multiple edges could.

### Neighborhood

A node $x_{j}\in V$ is a neighbor of the node $x_{i}\in V$ if there exists an edge $(x_{i},x_{j})\in E$. In terms of notation this relationship can be abbreviated by $x_{j}\sim x_{i}$, which should be read as "$x_{j}$ is a neighbor of $x_{i}$". Otherwise, if $x_{j}$ is not a neighbor of $x_{i}$ one writes $x_{j}\not \sim x_{i}$. The neighborhood ${\mathcal {N}}(x_{i})$ of a vertex $x_{i}\in V$ is simply the set of neighbors ${\mathcal {N}}(x_{i}):=\{x_{j}\in V\colon x_{j}\sim x_{i}\}$. The degree of a vertex $x_{i}\in V$ is the weighted size of its neighborhood:
    $\deg(x_{i}):=\sum _{j\,:\,x_{j}\sim x_{i}}w(x_{i},x_{j}).$
Note that in the special case where $w\equiv 1$ on $E$ (i.e. the graph is unweighted) we have $\deg(x_{i}):=|{\mathcal {N}}(x_{i})|$.

### Space of real vertex functions

Let ${\mathcal {H}}(V):=\{f:V\rightarrow \mathbb {R} \}$ be the space of (real) vertex functions.
Since $V$ is a finite set, any vertex function $f\in {\mathcal {H}}(V)$ can be represented as a $n$-dimensional vector $f\in \mathbb {R} ^{n}$ (where $n:=|V|$) and hence the space of vertex functions ${\mathcal {H}}(V)$ can be identified with an $n$-dimensional Hilbert space: ${\mathcal {H}}(V)\cong \mathbb {R} ^{n}$. The inner product of ${\mathcal {H}}(V)$ is defined as:
    $\langle f,g\rangle _{{\mathcal {H}}(V)}:=\sum _{x_{i}\in V}f(x_{i})g(x_{i}),\quad \forall f,g\in {\mathcal {H}}(V).$
Furthermore, for any vertex function $f\in {\mathcal {H}}(V)$ the $\ell _{p}$-norm and $\ell _{\infty }$-norm of $f$ are defined as:
    $\|f\|_{p}={\begin{cases}\left(\sum _{x_{i}\in V}|f(x_{i})|^{p}\right)^{\frac {1}{p}},&{\text{ for }}1\leqslant p<\infty \ ,\\\max _{x_{i}\in V}|f(x_{i})|,&{\text{ for }}p=\infty \ .\end{cases}}$
The $\ell _{2}$-norm is induced by the inner product.
In applications vertex functions are useful to label the vertices of the nodes. For example, in graph-based data clustering, each node represents a data point and a vertex function is used to identify cluster membership of the nodes.

### Space of real edge functions

Analogously to real vertex functions, one can introduce the space of real edge functions ${\mathcal {H}}(E):=\{F:E\rightarrow \mathbb {R} \}$. As any edge function $F$ is defined on a finite set of edges $E$, it can be represented as a $m$-dimensional vector $F\in \mathbb {R} ^{m}$, where $m:=|E|$. Hence, the space of edge functions ${\mathcal {H}}(E)$ can be identified as a $m$-dimensional Hilbert space, i.e., ${\mathcal {H}}(E)\cong \mathbb {R} ^{m}$.
One special case of an edge function is the normalized edge weight function $w\colon E\rightarrow (0,1]$ introduced above in the section on basic definitions. Similar to that function, any edge function $F$ can be trivially extended to $V\times V$ by setting $F(x_{i},x_{j}):=0$ if $(x_{i},x_{j})\not \in E$. The space of those extended edge functions is still denoted by ${\mathcal {H}}(E)$ and can be identified with $\mathbb {R} ^{m}$, where now $m:=|V|^{2}$.
The inner product of ${\mathcal {H}}(E)$ is defined as:
    $\langle F,G\rangle _{{\mathcal {H}}(E)}:=\sum _{(x_{i},x_{j})\in E}F(x_{i},x_{j})G(x_{i},x_{j}),\quad \forall F,G\in {\mathcal {H}}(E).$
Additionally, for any edge function $F\in {\mathcal {H}}(V)$ the $\ell _{p}$-norm and $\ell _{\infty }$-norm of $F$ are defined as:
    $\|F\|_{p}={\begin{cases}\left(\sum _{(x_{i},x_{j})\in E}|F(x_{i},x_{j})|^{p}\right)^{\frac {1}{p}}&{\text{ for }}1\leqslant p<\infty \ ,\\\max _{(x_{i},x_{j})\in E}|F(x_{i},x_{j})|,&{\text{ for }}p=\infty \ .\end{cases}}$
The $\ell _{2}$-norm is induced by the inner product.
If one extends the edge set $E$ in a way such that $E=V\times V$ than it becomes clear that ${\mathcal {H}}(E)\cong \mathbb {R} ^{n\times n}$ because ${\mathcal {H}}(V)\cong \mathbb {R} ^{n}$. This means that each edge function can be identified with a linear matrix operator.

## Differential graph operators

An important ingredient in the calculus on finite weighted graphs is the mimicking of standard differential operators from the continuum setting in the discrete setting of finite weighted graphs. This allows one to translate well-studied tools from mathematics, such as partial differential equations and variational methods, and make them usable in applications which can best be modeled by a graph. The fundamental concept which makes this translation possible is the graph gradient, a first-order difference operator on graphs. Based on this one can derive higher-order difference operators, e.g., the graph Laplacian.

### First-order differential operators
#### Weighted differences

Let $G=(V,E,w)$ be a finite weighted graph and let $f\in {\mathcal {H}}(V)$ be a vertex function. Then the weighted difference (or weighted graph derivative) of $f$ along a directed edge $(x_{i},x_{j})\in E$ is
    $\partial _{x_{j}}f(x_{i})\ :=\ {\sqrt {w(x_{i},x_{j})}}\left(f(x_{j})-f(x_{i})\right).$
For any weighted difference the following properties hold:
* $\partial _{x_{i}}f(x_{j})=-\partial _{x_{j}}f(x_{i}),$
* $\partial _{x_{i}}f(x_{i})=0,$
* $f(x_{i})=f(x_{j})\Rightarrow \partial _{x_{j}}f(x_{i})=0.$

#### Weighted gradient

Based on the notion of weighted differences one defines the weighted gradient operator on graphs $\nabla _{w}:{\mathcal {H}}(V)\rightarrow {\mathcal {H}}(E)$ as
    $(\nabla _{w}f)(x_{i},x_{j})\ =\ \partial _{x_{j}}f(x_{i}).$
This is a linear operator.
To measure the local variation of a vertex function $f$ in a vertex $x_{i}\in V$ one can restrict the gradient $\nabla _{w}f$ of $f$ to all directed edges starting in $x_{i}$ and using the $\ell _{p}$-norm of this edge function, i.e.,
    $\|(\nabla _{w}f)(x_{i},\cdot )\|_{\ell _{p}}={\begin{cases}\left(\sum _{x_{j}\sim x_{i}}w(x_{i},x_{j})^{\frac {p}{2}}|f(x_{j})-f(x_{i})|^{p}\right)^{\frac {1}{p}}&{\text{ for }}1\leq p<\infty ,\\\max _{x_{j}\sim x_{i}}{\sqrt {w(x_{i},x_{j})}}|f(x_{j})-f(x_{i})|&{\text{ for }}p=\infty .\end{cases}}$

#### Weighted divergence

The adjoint operator $\nabla _{w}^{*}\colon {\mathcal {H}}(E)\rightarrow {\mathcal {H}}(V)$ of the weighted gradient operator is a linear operator defined by
    $\langle \nabla _{w}f,G\rangle _{{\mathcal {H}}(E)}=\langle f,\nabla _{w}^{*}G\rangle _{{\mathcal {H}}(V)}\quad {\text{ for all }}f\in {\mathcal {H}}(V),G\in {\mathcal {H}}(E).$
For undirected graphs with a symmetric weight function $w\in {\mathcal {H}}(E)$ the adjoint operator $\nabla _{w}^{*}$ of a function $F\in {\mathcal {H}}(E)$ at a vertex $x_{i}\in V$ has the following form:
    $\left(\nabla _{w}^{*}F\right)(x_{i})\ =\ {\frac {1}{2}}\sum _{x_{j}\sim x_{i}}{{\sqrt {w(x_{i},x_{j})}}(F(x_{j},x_{i})-F(x_{i},x_{j}))}.$
One can then define the weighted divergence operator on graphs via the adjoint operator as $\operatorname {div} _{w}:=-\nabla _{w}^{*}$. The divergence on a graph measures the net outflow of an edge function in each vertex of the graph.

### Second-order differential operators
#### Graph Laplace operator

The weighted graph Laplacian $\Delta _{w}:{\mathcal {H}}(V)\rightarrow {\mathcal {H}}(V)$ is a well-studied operator in the graph setting. Mimicking the relationship $\operatorname {div} (\nabla f)=\Delta f$ of the Laplace operator in the continuum setting, the weighted graph Laplacian can be derived for any vertex $x_{i}\in V$ as:
    ${\begin{aligned}(\operatorname {div} _{w}(\nabla _{w}f))(x_{i})&={\frac {1}{2}}\sum _{x_{j}\sim x_{i}}{\sqrt {w(x_{i},x_{j})}}(\nabla _{w}f(x_{j},x_{i})-\nabla _{w}f(x_{i},x_{j}))\\&={\frac {1}{2}}\sum _{x_{j}\sim x_{i}}{\sqrt {w(x_{i},x_{j})}}\left({\sqrt {w(x_{i},x_{j})}}(f(x_{j})-f(x_{i}))-{\sqrt {w(x_{j},x_{i})}}(f(x_{i})-f(x_{j}))\right)\\&={\frac {1}{2}}\sum _{x_{j}\sim x_{i}}w(x_{i},x_{j})(2f(x_{j})-2f(x_{i}))\\&=\sum _{x_{j}\sim x_{i}}w(x_{i},x_{j})(f(x_{j})-f(x_{i}))\ =:\ (\Delta _{w}f)(x_{i}).\end{aligned}}$
Note that one has to assume that the graph $G$ is undirected and has a symmetric weight function $w(x_{i},x_{j})=w(x_{j},x_{i})$ for this representation.

#### Graph p-Laplace operators

The continuous $p$-Laplace operator is a second-order differential operator that can be well-translated to finite weighted graphs. It allows the translation of various partial differential equations, e.g., the heat equation, to the graph setting.
Based on the first-order partial difference operators on graphs one can formally derive a family of weighted graph $p$-Laplace operators $\Delta _{w,p}\colon {\mathcal {H}}(V)\rightarrow {\mathcal {H}}(V)$ for $1\leq p<\infty$ by minimization of the discrete $p$-Dirichlet energy functional
    $E(f)\ :=\ {\frac {1}{p}}\sum _{x_{i}\in V}\|\nabla _{w}f(x_{i},\cdot )\|_{\ell _{p}}^{p}.$
The necessary optimality conditions for a minimizer of the energy functional $E$ lead to the following definition of the graph $p$-Laplacian:
    $(\Delta _{w,p}f)(x_{i})\ :=\ \sum _{x_{j}\sim x_{i}}w(x_{i},x_{j})^{\frac {p}{2}}|f(x_{j})-f(x_{i})|^{p-2}(f(x_{j})-f(x_{i})).$
Note that the graph Laplace operator is a special case of the graph $p$-Laplace operator for $p=2$, i.e.,
    $(\Delta _{w,2}f)(x_{i})\ =\ (\Delta _{w}f)(x_{i})\ =\ \sum _{x_{j}\sim x_{i}}w(x_{i},x_{j})(f(x_{j})-f(x_{i})).$

## Applications

Calculus on finite weighted graphs is used in a wide range of applications from different fields such as image processing, machine learning, and network analysis. A non-exhaustive list of tasks in which finite weighted graphs have been employed is:
* image denoising
* image segmentation
* image inpainting
* tomographic reconstruction
* inverse problems
* data clustering
* point cloud compression
* hand-written digit recognition