# Bakry–Émery Curvature Sharpness and Curvature Flow in Finite Weighted Graphs: Implementation

^{1}

^{2}

^{3}

^{4}

^{5}

^{*}

## Abstract

**:**

## 1. Introduction

#### 1.1. Bakry–Émery Curvature and Curvature Sharpness

**Definition**

**1**

**.**The Bakry–Émery curvature of a non-isolated vertex $x\in V$ for a fixed dimension $N\in (0,\infty ]$ is the supremum of all values $K\in \mathbb{R}$, satisfying the curvature-dimension inequality

**Definition**

**2**

**.**Let $(G,P)$ be a weighted graph and $N\in (0,\infty ]$. A vertex $x\in V$ is called N-curvature sharp if we have

#### 1.2. Reformulation of Curvature via a Schur Complement

**Theorem**

**1**

**.**Let $(G,P)$ be a Markovian weighted graph and $x\in V$ be a non-isolated vertex with ${S}_{1}\left(x\right)=\{{y}_{1},\dots ,{y}_{m}\}$. Then, the following statements are equivalent:

- (1)
- x is curvature sharp;
- (2)
- x is curvature sharp for dimension $N=2$;
- (3)
- We have$$Q\left(x\right){\mathbf{1}}_{m}=\frac{1}{2}{K}_{P,\infty}^{d(x,\xb7)}\left(x\right){\mathbf{p}}_{x},$$

#### 1.3. Curvature Flow

**Definition**

**3**

**.**Let $(G,{P}_{0})$ be a finite weighted graph. The associated curvature flow is given by the following differential equations for all non-isolated vertices $x\in V$ and all $t\ge 0$:

**Theorem**

**2**

**.**Let $(G,{P}_{0})$ be a Markovian weighted graph. Then, the curvature flow ${(G,P\left(t\right))}_{t\ge 0}$ associated with $(G,{P}_{0})$ with normalization (8) is well defined for all $t\ge 0$ and preserves the Markovian property. If $(G,{P}_{0})$ is non-degenerate, then $(G,P(t\left)\right)$ is also non-degenerate for all $t\ge 0$. Moreover, if the flow converges for $t\to \infty $ to ${P}^{\infty}={lim}_{t\to \infty}P\left(t\right)$, then the weighted graph $(G,{P}^{\infty})$ is curvature sharp.

#### 1.4. Other Discrete Curvature Flows

## 2. Curvature Flow Examples

**Conjecture**

**1**

#### 2.1. Random Graphs

**Example**

**1**

**.**Let $(G,{P}_{0})$ be the unmixed weighted Markovian graph with vertex set $V=\{{v}_{0},\dots ,{v}_{9}\}$ and

`‘norm_tolerance’ has been exceeded at one or more vertices, at time t = … Would you like to:`

`A = Stop calculation and return list of P-matrices so far`

`B = Apply manual normalization now, and apply it again when necessary without asking (you will still be notified when it is applied)`

`C = Apply manual normalization now, and ask again before reapplying it`

`Please enter A, B or C here:`

`‘B’`, the program will continue with its flow calculations without further interruptions, and the user is simply notified about the times at which the program applies further artificial normalizations of the transition rates. The user can suppress this message entirely by changing line 2 of the program into “

`stoch_corr = True`”, in which case the program applies stochastic corrections automatically, each time with the message

`Transition rates have been artificially normalized at time t = …`

**Conjecture**

**2.**

#### 2.2. Paths and Cycles

**Example**

**2**

**.**Figure 4 presents numerical curvature flow limits of a Markovian weighted path with vertices 12 vertices (left-hand side) and of a weighted cycle with 12 vertices (right-hand side). The non-zero transition rates of the initial weighting scheme ${P}_{0}={\left({p}_{ji}\right)}_{0\le i,j\le 11}$ for the path limit in Figure 4 were chosen as follows:

${p}_{0,1}$ | ${p}_{1,2}$ | ${p}_{2,3}$ | ${p}_{3,4}$ | ${p}_{4,5}$ | ${p}_{5,6}$ | ${p}_{6,7}$ | ${p}_{7,8}$ | ${p}_{8,9}$ | ${p}_{9,10}$ | ${p}_{10,11}$ |

1 | $0.25$ | $0.72$ | $0.46$ | $0.23$ | 019 | $0.84$ | $0.71$ | $0.62$ | $0.9$ | $0.55$ |

${p}_{1,0}$ | ${p}_{2,1}$ | ${p}_{3,2}$ | ${p}_{4,3}$ | ${p}_{5,4}$ | ${p}_{6,5}$ | ${p}_{7,6}$ | ${p}_{8,7}$ | ${p}_{9,8}$ | ${p}_{10,9}$ | ${p}_{11,10}$ |

$0.75$ | $0.28$ | $0.54$ | $0.77$ | $0.81$ | $0.16$ | $0.29$ | $0.38$ | $0.1$ | $0.45$ | 1 |

`display_weighted_graph`as dotted black lines (see, e.g., the edges $\{{v}_{2},{v}_{9}\}$ and $\{{v}_{8},{v}_{9}\}$ on the right hand side of Figure 1).

**Proposition**

**1**

**.**Let $(G,{P}_{0})$ be a weighted path of length $N\ge 3$ with consecutive vertices ${v}_{0},\dots ,{v}_{N-1}$. Let $P\left(t\right)$ be its corresponding curvature flow converging to a limit ${P}^{\infty}={lim}_{t\to \infty}P\left(t\right)$, such that $(G,{P}^{\infty})$ does not have two-sided degenerate edges. Then, this limit is neither totally degenerate nor is it not non-degenerate (that is, it contains both green and dashed red edges). Moreover, the components of the non-degenerate subgraph ${G}_{W}$ are paths of lengths $\le 2$, and they are separated from each other by at least two degenerate edges. If a component of ${G}_{W}$ is a path of length 1, that is, just one edge $\{{v}_{j},{v}_{j+1}\}$, then we have ${p}_{j,j+1}^{\infty}={p}_{j+1,j}^{\infty}=1$.

**Proof.**

**Proposition**

**2.**

**Proof.**

#### 2.3. Complete Graphs

**Example**

**3**

**.**Let $(G,{P}_{0})$ be the complete weighted Markovian graph with vertex set $V=\{{v}_{0},\dots ,{v}_{5}\}$ and

**Conjecture**

**3**

**.**Let ${P}_{0}$ be a Markovian weighting scheme without laziness on a complete graph ${K}_{n}=(V,E)$ with $n\ge 2$ such that, for every proper subset $W\subset V$, there exist $x,{x}^{\prime}\in W$ and $y,{y}^{\prime}\in \in V\backslash W$ with ${p}_{xy}>0$ and ${p}_{{y}^{\prime}{x}^{\prime}}>0$. Then, the curvature flow has a limit ${P}^{\infty}$, which is the simple random walk.

#### 2.4. Wedge Sums of Complete Graphs

**Example**

**4**

**.**We consider the curvature flow on the wedge sum $G=(V,E)$ of complete graphs presented in Figure 7 with random initial weighting schemes $P={P}_{0}$. The adjacency matrix A of this graph is generated with our code in the following way:

**Example**

**5**

**.**The weighted graph $(G,{P}_{0})$ in this example is a wedge sum of a ${K}_{5}$, ${K}_{2}$ and another ${K}_{5}$, together with a simple random walk as initial weighting scheme (see line 4 in the code). This situation can be set up by the following code:

#### 2.5. Cartesian Products of Complete Graphs

**Theorem**

**3.**

**Proof.**

**Example**

**6**

**.**The following code computes the numerical flow limit for ${K}_{3}\times {K}_{4}$ with the simple random walk as initial weighting scheme.

#### 2.6. Totally Degenerate Flow Limits

**Example**

**7**

**.**Let $G=(V,E)$ with $V=\{{v}_{0},\dots ,{v}_{5}\}$ be the unmixed graph representing the octahedron, as illustrated in Figure 12 (left hand side). While the simple random walk without laziness is a stationary solution of the normalized curvature flow, any small perturbation of this initial weighting scheme leads to another curvature sharp limit, which is totally degenerate. For example, the initial weighting scheme

**Lemma**

**1.**

**Proof.**

**Proposition**

**3.**

**Proof.**

**Conjecture**

**4**

**.**The normalized curvature flow on the octahedron for any non-degenerate initial weighting scheme without laziness different from the simple random walk always converges to a limit described in Proposition 3.

## 3. Asymptotically Stable and Unstable Curvature Sharp Markovian Weighting Schemes

#### 3.1. Linearization of the Curvature Flow Equations at Equilibria

**Remark**

**1.**

#### 3.2. Examples of Asymptotically Stable and Unstable Equilibria

**Example**

**8**

**.**Let ${C}_{N}=(V,E)$ be a cycle of length $N\ge 4$, that is, $V=\{{v}_{0},{v}_{1},\dots ,{v}_{N-1}\}$ and ${v}_{i}\sim {v}_{i+1}$ with indices i modulo N. For simplicity, we refer to vertex ${v}_{i}$ henceforth as i. We assume ${P}^{s}$ to be a non-lazy curvature sharp weighting scheme on ${C}_{N}$, and we remove the directed edges $(i,i+1)\in {E}^{\mathrm{dir}}$ to obtain ${E}^{\mathrm{ess}}$, and the only coefficients ${B}_{{a}_{j}}\left({a}_{k}\right)$ with ${a}_{j}\in {E}^{\mathrm{ess}}$ and ${a}_{k}\in {E}^{\mathrm{dir}}$, which may be potentially non-zero are (see (13)–(16)),

**Example**

**9**

**.**We know from Example 7 that stationary solutions of the normalized curvature flow on the octahedron are the simple random walk without laziness as well as the totally degenerate weighting scheme given as matrix ${P}^{s}$ in the following code (see also the right-hand side of Figure 12). The linearization $DF\left({P}^{s}\right)$ is analyzed in line 10 of the program, and the function

`equilibrium_type`with the parameters chosen in lines 6 and 7 returns one of the values $-1,0,1$ (corresponding to “asymptotically stable”, ”undecided”, “unstable”, respectively), followed by a list of its eigenvalues. That is, after execution of line 10,

`result[0]`is one of the values $-1,0,1$ and

`result[1]`is a list of the 18 eigenvalues ${\lambda}_{j}$ of $DF\left({P}^{s}\right)$.

${\lambda}_{j}$ | $-1$ | $-1+i$ | $-1-i$ | $-2$ | $-2+i$ | $-2-i$ | $-3$ | $-4$ |

multiplicity | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 4 |

${\lambda}_{j}$ | $0.5$ | 0 | $-0.75$ | $-1$ | $-1.5$ |

multiplicity | 3 | 3 | 2 | 6 | 4 |

**Example**

**10**

**.**Let ${K}_{n+1}=(V,E)$ be the complete unmixed graph with $n+1\ge 3$ vertices. Instead of the B-coefficients, we make use of the ${B}^{\prime}$-coefficients introduced in Remark 1. The simple random walk ${p}_{xy}=\frac{1}{n}$ for $x\ne y$ is a curvature sharp Markovian weighting scheme, and the non-zero ${B}^{\prime}$-coefficients are then given by

`n=2`into

`n=3`in line 1 of the code) is as follows:

- $-\frac{7}{16}$ with multiplicity 4, $-\frac{3}{4}$ with multiplicity 6, and $-\frac{7}{4}$ with multiplicity 5 for $n=4$;
- $-\frac{8}{25}$ with multiplicity 5, $-\frac{4}{5}$ with multiplicity 10, and $-\frac{8}{5}$ with multiplicity 9 for $n=5$;
- $-\frac{1}{4}$ with multiplicity 6, $-\frac{5}{6}$ with multiplicity 15, and $-\frac{3}{2}$ with multiplicity 14 for $n=6$;
- $-\frac{10}{49}$ with multiplicity 7, $-\frac{6}{7}$ with multiplicity 21, and $-\frac{10}{7}$ with multiplicity 20 for $n=7$.

**Conjecture**

**5.**

**Example**

**11**

**.**We know from [1] (Corollary 1.14) that the simple random walk without laziness on a hypercube ${Q}^{d}={\left({K}_{2}\right)}^{d}$ is curvature sharp, and it is the only non-degenerate curvature sharp weighting schemes without laziness if and only if d is odd. For $d=2$, a non-degenerate curvature sharp weighting scheme on ${Q}^{2}$ different from the simple random walk is given in line 4 of the following code:

**Conjecture**

**6.**

## 4. Conclusions and Open Questions

- (a)
- Random graphs: We observed an edge density threshold for Erdös-Rényi graphs. For values below this threshold, the flow usually converges to a totally degenerate limit, while for values above this threshold, the flow limit concentrates on a non-degenerate cluster (see Conjecture 2). Further research could encompass curvature flows of random regular graphs with simple random walks as their initial weighting schemes.
- (b)
- Paths and cycles: Our observed limits for these graphs are usually directed graphs with isolated clusters of three vertices (see Figure 4 and Proposition 1).
- (c)
- Complete graphs and their wedge sums and Cartesian products: In the case of complete graphs, non-degenerate initial weighting schemes seem to converge always to simple random walks (see Conjecture 3). In wedge sums of complete graphs, curvature flow limits usually concentrate totally on one of its components, which is most often the largest component (see Table 2). This observation might motivate further research on the largest clusters of general highly connected graphs. We also describe the flow limit of Cartesian products of complete graphs with the simple random walk as its initial weighting scheme (see Theorem 3). A natural question here is the limit behavior of Cartesian products of graphs with curvature sharp initial weighting schemes.
- (d)
- Octahedron: In the case of the octahedron, there is a unique totally degenerate flow limit (up to symmetries), which has two sources and a directed 4-cycle (see Figure 12 and Proposition 3). The shape of totally degenerate flow limits for general graphs is obscure and would benefit from further investigations.

- (e)
- Cycles: Simple random walks on cycles ${C}_{n}$ for $n\ge 4$ are unstable, and totally degenerate directed weighting schemes are asymptotically stable (see Example 8).
- (f)
- Complete graphs: We have strong numerical evidence that simple random walks on complete graphs ${K}_{n}$ are asymptotically stable (numerically verified for $n=3,\dots ,8$); see Example 10. Moreover, our numerics provide explicit information about all eigenvalues of the linearized curvature flow as stated in Conjecture 5.
- (g)
- Hypercubes: Simple random walks of hypercubes ${Q}^{d}$ for $d\ge 2$ seem to be unstable and our experiments give rise to a conjecture about the largest eigenvalue of the linearized curvature flow (see Conjecture 6).
- (h)
- Octahedron: The totally degenerate flow limit of the octahedron is asymptotically stable (see Example 9).
- (i)
- Edge-transitive graphs: In view of (e), (f), and (g), an interesting research direction would be to investigate the stability of the simple random walk for general edge-transitive graphs.

## 5. Implementation of the Curvature Flow and Useful Tools

- Functions related to graphs and their adjacency matrices;
- Functions related to weighting schemes;
- Functions testing combinatorial and weighted graphs;
- Curvature flow computation routines;
- Curvature computation routines;
- Display routines.

#### 5.1. Functions Related to Graphs and Their Adjacency Matrices

`rand_adj_mat(n, p, connected=False)`;`complete(n)`;`path(n)`;`cycle(n)`;`wedge_sum(A, B, i, j)`;`bridge_at(A, B, i, j)`;`hypercube(n)`;`cart_prod(A, B)`;`onespheres(A)`.

`rand_adjmat(n, p)`returns a random adjacency matrix with

`n`vertices, where

`p`is the probability that an edge exists between any two vertices. Therefore, higher values of

`p`usually lead to better-connected graphs. Choosing

`connected=True`instead guarantees that the returned adjacency matrix provides a connected combinatorial graph.

`complete(n)`,

`path(n)`and

`cycle(n)`return the adjacency matrix of a complete graph with

`n`vertices, a path of length

`n`and a cycle of length

`n`, respectively.

`wedge_sum(A, B, i, j)`produces an adjacency matrix of a graph that is the wedge sum of two pointed graphs represented by the adjacency matrices

`A`and

`B`and the

`i`th vertex of

`A`and the

`j`th vertex of

`B`, that is, the new graph is obtained from the disjoint union of these two graphs by only identifying these two vertices and keeping all other edges and vertices disjoint.

`bridge_at(A, B, i, j)`, which returns an adjacency matrix of the graph formed by connecting the graphs represented by

`A`and

`B`by a single edge at the

`i`th vertex of

`A`and the

`j`th vertex of

`B`.

`hypercube(n)`returns the adjacency matrix of the

`n`-dimensional hypercube.

`A`and

`B`is returned by the function

`cart_prod(A, B)`. (The

`n`-dimensional hypercube can also be alternatively generated as the Cartesian product of n complete graphs ${K}_{2}$.)

`A`and the vertex set $V=\{0,1,\dots ,n-1\}$, the function

`onespheres(A)`returns a list of lists whose i-th entry is a list of all neighbors of vertex $i\in V$, and whose n-th entry is a list of the combinatorial degrees of the vertices in V. This function is mainly used in the execution of other functions.

#### 5.2. Functions Related to Weighting Schemes

`randomizer(A, threshold=0.001, laziness=False)`;`srw(A, laziness=False)`;`cart_prod_prob(P, Q, p, q)`.

`randomizer(A)`and

`srw(A)`are two useful functions that can be used to give weighted matrices from an adjacency matrix.

`randomizer(A)`returns a weighting scheme for the graph G with random, numerically non-degenerate transition rates, that is, no transition rate is chosen to be below the parameter

`threshold`. Usually, the returned weighting schemes are without laziness, but choosing

`laziness=True`returns weighting schemes with all vertices having laziness ≥

`threshold`.

`srw(A)`returns the weighting scheme corresponding to the non-lazy simple random walk on the graph $G=(V,E)$ represented by the adjacency matrix

`A`. Choosing

`laziness=True`, the transition rates of a vertex $v\in V$ with degree n to its neighbors are chosen to be $\frac{1}{n+1}$ and its laziness is also chosen to be $\frac{1}{n+1}$.

`cart_prod_prob(P, Q, p, q)`is a “weighted” analog of the function

`cart_prod`from the previous subsection for the Cartesian product of two weighting schemes

`P`,

`Q`with weights

`p`,

`q`, with $\mathtt{p}+\mathtt{q}=1$. If

`P`and

`Q`are of size n and m, respectively, this function returns the matrix $\mathtt{p}\mathtt{P}\otimes {I}_{n}+\mathtt{q}{I}_{m}\otimes \mathtt{Q}$ of size $nm$, where ${I}_{n}$ is the identity matrix of size n and $A\otimes B$ is the Kronecker product of A and B.

#### 5.3. Functions Testing Combinational and Weighted Graphs

`A`and weighted graphs given additionally by their weighting scheme

`P`, we have the following test functions:

`is_connected(A)`;`is_weakly_connected(A, threshold=0.001)`;`is_totally_degenerate(A, P, threshold=0.001)`;`is_markovian(P, norm_tolerance=0.001)`;`is_curvature_sharp(A, P, norm_tolerance=0.001, threshold=0.001)`;`equilibrium_type(A, P, eigenvalues=False, jacobi_matrix=False,``norm_tolerance=0.001, threshold=0.001)`.

`is_connected(A)`returns

`True`if and only if the adjacency matrix

`A`represents a connected graph.

`is_weakly_connected(P)`is a “weighted” analog, which returns

`True`if and only if the weighted matrix

`P`represents a weakly connected graph. It does this by forming an adjacency matrix with a

`1`in the $(\mathtt{i},\mathtt{j})$th entry if and only if

`P[i, j] > threshold`or

`P[j, i] > threshold`and then testing for connectedness.

`threshold`. The function

`is_totally_degenerate(A,P)`tests this property.

`is_markovian(P)`tests whether the entries of each of the columns of P add up numerically to 1 up to an error $\le \mathtt{norm}\_\mathtt{tolerance}$.

`(A,P)`is tested by

`is_curvature_sharp(A,P)`. If

`(A,P)`fails to be Markovian (with respect to

`norm_tolerance`), this function returns

`NONE`and gives notice to the user by an error message.

`equilibrium_type(A,P)`, which always returns a list of length three. The function checks first whether

`(A,P)`satisfies the Markovian property and is numerically curvature sharp. If this is not the case, it returns a list of three

`NONE`values. Otherwise, the function investigates the real parts of the eigenvalues ${\lambda}_{j}$ of the linearized curvature flow matrix at the equilibrium

`P`. The first entry of the return list is $-1,0$ or 1 depending on the maximum ${max}_{j}\mathrm{Re}\left({\lambda}_{j}\right)$. If this maximum is $\ge \mathtt{threshold}$, the return value is 1 (for “unstable”) and if this maximum is $\le -\mathtt{threshold}$, the return value is $-1$ (for “asymptotically stable”). Otherwise, the dynamical nature of the equilibrium cannot be numerically decided and the function returns the value 0. The following two entries of the return list are usually

`NONE`unless the user made the choices

`eigenvalues=True`or

`jacobi_matrix=True`. In the first case, the second entry of the return list is a list of all eigenvalues of the linearized curvature flow matrix, and in the second case the third entry of the return is the linearized curvature flow matrix itself.

#### 5.4. Curvature Flow Computation Routines

`curv_flow(A, P, t_max, dt=0.3, C=zeroes)`,`norm_curv_flow(A, P, t_max, dt=0.3, stoch_corr=True, norm_tolerance=0.001)`,`norm_curv_flow_lim(A, P, dt=0.3, stoch_corr=True, norm_tolerance=0.001, lim_tolerance=0.001, t_lim=10000)`.

`A`describing the topology of the graph G and the weighting scheme

`P`containing the initial probability transitions ${p}_{xy}\left(0\right)$.

`curv_flow(A,P)`computes the non-normalized numerical curvature flow with coefficients ${C}_{x}\left(t\right)=0$ in (7). If users decide to choose other coefficient functions, they need to modify the input parameter

`C=zeroes`. Note that

`zeroes(A,P)`is a function returning simply a list of zeroes of length $\left|V\right|$. Users can investigate modifications of the curvature flow by choosing their own coefficient functions with input values

`(A,P)`and returning a list of length $\left|V\right|$ of real values. Using the discretization parameter

`dt=0.3`for the discrete time steps starting at

`t=0`, the curvature flow routine creates a list

`P_list`of weighting schemes (represented by NumPy arrays of size $\left|V\right|\times \left|V\right|$) at each time increment using the Runge–Kutta algorithms RK4. There are two internal subroutines involved, which we would like to mention briefly.

`Pvecs_to_P`translates a weighting scheme given by a list of lists (where each inner list contains the transition rates of the corresponding vertex) into the corresponding NumPy array.

`Pvecs_prime`computes, for a given weighting scheme

`P`, the right-hand side of the ordinary differential equations describing the curvature flow. The representation of this right-hand side is again a list of lists, as described before. The computation stops just before the discrete time steps exceed the limit time

`t_max`and the routine returns

`P_list`. Note that in this general setting, transition rates can assume arbitrary values and even negative ones or diverge to infinity in finite time which may lead to system error messages. Users need to be aware of this possibility.

`norm_curv_flow(A,P)`. This special flow is the main focus of this paper and could also be mimicked by choosing

`C=K_inf`in

`curv_flow`. The function

`K_inf(A,P)`returns a list of upper curvature bounds for all vertices of the Markovian weighted graph represented by

`(A,P)`(see [1] (Formula (66)) for an explicit expression of this function in terms of transition rates). During the numerical computations of subsequent time steps, the Markovian property of the corresponding weighting schemes may be slightly violated. If this violation exceeds the threshold

`norm_tolerance`, the routine prepares for a potential correction according to the Boolean variable

`stoch_corr`. If

`stoch_corr=False`, the program stops with a message to the user as discussed in Example 1. Otherwise, the program carries out the following automatic Markovian renormalization of the currently considered weighting scheme: while the diagonal entries (the laziness values) are unchanged, the off-diagonal entries in each row are rescaled by a suitable factor to guarantee that the resulting matrix becomes stochastic again. As before, this routine returns a list

`P_list`of consecutive weighting schemes up to the time limit

`t_max`.

`t_max`in the above two routines, the third routine

`norm_curv_flow_lim(A,P)`continues computing the normalized numerical curvature flow until a numerical flow limit is reached. This limit is determined by the parameter

`lim_tolerance`. The details for this numerical limit are explained in the introductory part of Section 2. This routine returns a list of length two: the limiting weighting scheme as a NumPy array followed by the numerical convergence time. Since it may happen that a normalized numerical flow does not converge at all (even though we are not aware of any such example), the parameter

`t_lim`provides an upper time limit beyond which the routine will not continue. The parameters

`stoch_corr`and

`norm_tolerance`play the same role as in the routine

`norm_curv_flow`.

#### 5.5. Curvature Computation Routines

`curvatures(A, P, N=inf, onesps=[], q=None)`;`calc_curvatures(A, P_list, N=inf, k=1)`;`K_inf(A, P)`;`calc_curv_upper_bound(A, P_list, N=inf, k=1)`.

`curvatures(A,P)`computes, for a weighted graph $(G,P)$ with $G=(V,E)$ and represented by

`(A,P)`, the curvatures of all vertices for dimension

`N`$=\infty $ and returns them as a list of length $\left|V\right|$. If users are interested in curvatures for other dimensions, they need to change the parameter

`N=inf`. There are two other inputs that can speed up the curvature calculations: if the number

`q`of vertices in V is given, it can be specified to avoid its repeated recalculation, for example, during a curvature flow process. Similarly, if

`onespheres(A)`has already been calculated earlier, this information can be communicated to the routine via the input variable

`onesps`.

`P_list`of consecutive weighting schemes, the routine

`calc_curvatures(A,P_list)`computes the corresponding evolution of vertex curvatures by calling

`curvatures(A,P_list[j])`and returns it as a list of lists. Here, the j-th inner list contains the curvature evolution of the j-th vertex of the graph $G=(V,E)$ represented by

`A`. The dimension parameter

`N=inf`plays the same role as before.

`calc_curvatures`computes curvatures only of each

`k`-th weighting scheme provided by

`P_list`. Where appropriate, this can help to reduce computation time.

`K_inf(A,P)`was already discussed in the previous subsection and provides a list of upper curvature bounds for all vertices of the weighted graph $(G,P)$ represented by

`(A,P)`.

`calc_curv_upper_bound`is completely analogous to

`calc_curvatures`, but it calls

`K_inf`instead of

`curvatures`.

#### 5.6. Display Routines

`display_curvatures(curv, dt=0.3, is_Markovian=True, N=inf, k=1,``curv_bound=[], vertex_list=[])`;`display_trans_rates(A, P_list, dt=0.3, vertex_list=[])`;`display_weighted_graph(A, P, title=None, threshold=10**(-3),``display_options=[10, True, 2, []], laziness=False)`.

`display_curvatures(curv)`displays the curvature evolution for each consecutive vertex separately, as illustated, for example, in Figure 3. If this information should be only given for specific vertices, this can be specified by the input parameter

`vertex_list`. The time step

`dt=0.3`and the value of

`k`together determine the labeling of the horizontal time axis. For the role of

`k`, we refer readers to our explanation about the routine

`calc_curvatures`. Upper curvature bounds can be inserted into the displays by the input parameter

`curv_bound`, which needs to be given in the same format as the vertex curvatures. Constant lower and upper curvature bounds $-1$ and 2 are plotted alongside if the Boolean

`is_Markovian`is chosen to be

`True`and if the dimension parameter

`N`is $\ge 2$. These bounds appear, for example, in the illustrations given in Figure 3.

`A`by a list

`P_list`of NumPy arrays,

`display_trans_rates(A,P_list)`displays the evolution of transition rates of emanating edges for each consecutive vertex separately, as illustrated, for example, in Figure 2. The input parameters

`dt`and

`vertex_list`play the same role as in the previous routine.

`display_graph(A,P)`with input parameters

`A`and

`P`representing a weighted graph $(G,P)$. This routine produces a MatPlotLib plot of this weighted graph, with the vertices arranged counter-clockwise in a circle. The plot uses the following convention to illustrate different types of edges:

- Green, solid lines represent numerically non-degenerate edges, that is $\{x,y\}\in E$ with both ${p}_{xy},{p}_{yx}\ge $
`threshold`; - Red, dashed lines with an arrow represent numerically degenerate edges, that is, $\{x,y\}\in E$ with exactly one of ${p}_{xy}$ and ${p}_{yx}$ strictly less than
`threshold`; - Black, dotted lines represent edges with numerically vanishing transition rates in both directions, that is $\{x,y\}\in E$ with both ${p}_{xy},{p}_{yx}$ strictly less than
`threshold`.

`title`. For Markovian weighted graphs with non-vanishing laziness, the option

`laziness=True`labels each vertex with its corresponding laziness.

`display_options`of the

`display_graph`routine remains to be discussed. This parameter is a list of four entries. The first entry determines the size of the plot. Usually, the transition rates are printed above the edges, but if the second entry is chosen to be

`False`, this information about the transition rates is omitted. Otherwise, the transition rates are given to a number of decimal places determined by the third entry. The default positions of these transition rates are $\frac{1}{6}$ of the way along the edges, with the number closest to the vertex x in the edge $(x,y)$ being ${p}_{xy}$, but this can be altered manually to avoid overlapping by specification in the fourth entry of

`display_options`. For example, if one wishes the ${p}_{45}$ label to be moved to a position $\frac{1}{4}$ of the way from vertex 4 to vertex 5 and the ${p}_{62}$ label to be moved to a position $\frac{1}{5}$ of the way from vertex 6 to vertex 2, this fourth entry should be chosen to be

`[[4, 5, 1/4, 1/6], [6, 2, 1/5, 1/6]]`.

## Author Contributions

## Funding

## Data Availability Statement

## Acknowledgments

## Conflicts of Interest

## References

- Cushing, D.; Kamtue, S.; Liu, S.; Münch, F.; Peyerimhoff, N.; Snodgrass, H.B. Bakry-Émery curvature sharpness and curvature flow in finite weighted graphs. I. Theory. arXiv
**2022**, arXiv:2204.10064. [Google Scholar] - Cushing, D.; Kamtue, S.; Liu, S.; Münch, F.; Peyerimhoff, N.; Snodgrass, H.B. Bakry-Émery curvature sharpness and curvature flow in finite weighted graphs. II. Implementation. arXiv
**2022**, arXiv:arxiv.2212.12401. [Google Scholar] - Gallot, S.; Hulin, D.; Lafontaine, J. Riemannian Geometry, 3rd ed.; Springer: Berlin/Heidelberg, Germany, 2004. [Google Scholar]
- Bakry, D.; Émery, M. Hypercontractivité de semi-groupes de diffusion. C. R. Acad. Sci. Paris Sér. I Math.
**1984**, 299, 775–778. [Google Scholar] - Elworthy, K.D. Manifolds and graphs with mostly positive curvatures. In Stochastic Analysis and Applications (Lisbon, 1989); Progress in Probability; Birkhäuser Boston: Boston, MA, USA, 1991; Volume 26, pp. 96–110. [Google Scholar]
- Schmuckenschläger, M. Curvature of nonlocal Markov generators. In Convex Geometric Analysis (Berkeley, CA, 1996); Mathematical Sciences Research Institute Publications; Cambridge University Press: Cambridge, MA, USA, 1999; Volume 34, pp. 189–197. [Google Scholar]
- Lin, Y.; Yau, S.T. Ricci curvature and eigenvalue estimate on locally finite graphs. Math. Res. Lett.
**2010**, 17, 343–356. [Google Scholar] [CrossRef] [Green Version] - Bauer, F.; Chung, F.; Lin, Y.; Liu, Y. Curvature aspects of graphs. Proc. Am. Math. Soc.
**2017**, 145, 2033–2042. [Google Scholar] [CrossRef] - Chung, F.; Lin, Y.; Yau, S.T. Harnack inequalities for graphs with non-negative Ricci curvature. J. Math. Anal. Appl.
**2014**, 415, 25–32. [Google Scholar] [CrossRef] - Fathi, Z.; Lakzian, S. Bakry-Émery Ricci curvature bounds for doubly warped products of weighted spaces. J. Geom. Anal.
**2022**, 32, 75. [Google Scholar] [CrossRef] [PubMed] - Fathi, M.; Shu, Y. Curvature and transport inequalities for Markov chains in discrete spaces. Bernoulli
**2018**, 24, 672–698. [Google Scholar] [CrossRef] [Green Version] - Hua, B.; Lin, Y. Graphs with large girth and nonnegative curvature dimension condition. Comm. Anal. Geom.
**2019**, 27, 619–638. [Google Scholar] [CrossRef] [Green Version] - Ma, L. Bochner formula and Bernstein type estimates on locally finite graphs. arXiv
**2013**, arXiv:1304.0290. [Google Scholar] - Man, S. Logarithmic Harnack inequalities for general graphs with positive Ricci curvature. Differ. Geom. Appl.
**2015**, 38, 33–40. [Google Scholar] [CrossRef] - Pouryahya, M.; Elkin, R.; Sandhu, R.; Tannenbaum, S.; Georgiou, T.; Tannenbaum, A. Bakry-Émery Ricci curvature on weighted graphs with applications to biological networks. In Proceedings of the International Symposium on Mathematical Theory of Networks and Systems, Bayreuth, Germany, 12–15 July 2016; Volume 22, p. 52. [Google Scholar]
- Robertson, S.J. Harnack Inequality for Magnetic Graphs. arXiv
**2019**, arXiv:1910.04019. [Google Scholar] - Salez, J. Sparse expanders have negative curvature. arXiv
**2021**, arXiv:2101.08242. [Google Scholar] [CrossRef] - Salez, J. Cutoff for non-negatively curved Markov chains. arXiv
**2021**, arXiv:2102.05597. [Google Scholar] [CrossRef] - Shi, Y.; Yu, C. Comparisons of Dirichlet, Neumann and Laplacian eigenvalues on graphs and applications. arXiv
**2020**, arXiv:2011.04160. [Google Scholar] - Cushing, D.; Liu, S.; Peyerimhoff, N. Bakry-Émery curvature functions on graphs. Can. J. Math.
**2020**, 72, 89–143. [Google Scholar] [CrossRef] [Green Version] - Klartag, B.; Kozma, G.; Ralli, P.; Tetali, P. Discrete curvature and abelian groups. Can. J. Math.
**2016**, 68, 655–674. [Google Scholar] [CrossRef] [Green Version] - Siconolfi, V. Coxeter groups, graphs and Ricci curvature. Sém. Lothar. Combin.
**2020**, 84B, 67. [Google Scholar] - Siconolfi, V. Ricci curvature, graphs and eigenvalues. Linear Algebra Appl.
**2021**, 620, 242–267. [Google Scholar] [CrossRef] - Cushing, D.; Kamtue, S.; Liu, S.; Peyerimhoff, N. Bakry-Émery curvature on graphs as an eigenvalue problem. Calc. Var. Partial Differential Equations
**2022**, 61, 62. [Google Scholar] [CrossRef] - Chow, B.; Luo, F. Combinatorial Ricci flows on surfaces. J. Differ. Geom.
**2003**, 63, 97–129. [Google Scholar] [CrossRef] - Ollivier, Y. Ricci curvature of Markov chains on metric spaces. J. Funct. Anal.
**2009**, 256, 810–864. [Google Scholar] [CrossRef] [Green Version] - Ollivier, Y. A survey of Ricci curvature for metric spaces and Markov chains. In Probabilistic Approach to Geometry; Advanced Studies in Pure Mathematics; Mathematical Society of Japan: Tokyo, Japan, 2010; Volume 57, pp. 343–381. [Google Scholar] [CrossRef]
- Ni, C.C.; Lin, Y.Y.; Luo, F.; Gao, J. Community detection on networks with Ricci flow. Sci. Rep.
**2019**, 9, 9984. [Google Scholar] [CrossRef] [Green Version] - Bai, S.; Lin, Y.; Lu, L.; Wang, Z.; Yau, S.T. Ollivier Ricci-flow on weighted graphs. arXiv
**2020**, arXiv:2010.01802. [Google Scholar] - Weber, M.; Saucan, E.; Jost, J. Characterizing complex networks with Forman-Ricci curvature and associated geometric flows. J. Complex Netw.
**2017**, 5, 527–550. [Google Scholar] [CrossRef] - Forman, R. Bochner’s method for cell complexes and combinatorial Ricci curvature. Discret. Comput. Geom.
**2003**, 29, 323–374. [Google Scholar] [CrossRef] - Topping, J.; Di Giovanni, F.; Chamberlain, B.P.; Dong, X.; Bronstein, M.M. Understanding over-squashing and bottlenecks on graphs via curvature. arXiv
**2021**, arXiv:2111.14522. [Google Scholar] - Bober, J.; Monod, A.; Saucan, E.; Webster, K.N. Rewiring Networks for Graph Neural Network Training Using Discrete Geometry. arXiv
**2022**, arXiv:2207.08026. [Google Scholar] - Erbar, M.; Maas, J. Ricci curvature of finite Markov chains via convexity of the entropy. Arch. Ration. Mech. Anal.
**2012**, 206, 997–1038. [Google Scholar] [CrossRef] - Erbar, M.; Kopfer, E. Super Ricci flows for weighted graphs. J. Funct. Anal.
**2020**, 279, 108607. [Google Scholar] [CrossRef] - Devriendt, K.; Lambiotte, R. Discrete curvature on graphs from the effective resistance. arXiv
**2022**, arXiv:2201.06385. [Google Scholar] [CrossRef] - Erdos, P.; Rényi, A. On random graphs. I. Publ. Math. Debrecen
**1959**, 6, 290–297. [Google Scholar] [CrossRef] - Pak, I. Lectures on Discrete and Polyhedral Geometry. 2010. Available online: https://www.math.ucla.edu/~pak/geompol8.pdf (accessed on 6 June 2023).
- Hirsch, M.W.; Smale, S. Differential Equations, Dynamical Systems, and Linear Algebra; Pure and Applied Mathematics; Academic Press: New York, NY, USA; Harcourt Brace Jovanovich, Publishers: London, UK, 1974; Volume 60. [Google Scholar]
- Cushing, D.; Kangaslampi, R.; Lipiäinen, V.; Liu, S.; Stagg, G.W. The Graph Curvature Calculator and the Curvatures of Cubic Graphs. Exp. Math.
**2022**, 31, 583–595. [Google Scholar] [CrossRef] [Green Version]

**Figure 1.**Curvature flow of a random graph with 10 vertices with initial weighting scheme ${P}_{0}$ (

**left**-hand side) and final weighting scheme $P\left({t}_{\mathrm{max}}\right)$ (

**right**-hand side).

**Figure 2.**Transition rates of vertices ${v}_{3}$ and ${v}_{8}$ of a random graph with 10 vertices under the curvature flow.

**Figure 3.**Curvatures (blue) and upper curvature bounds (orange) of vertices ${v}_{1}$ and ${v}_{9}$ of a random graph with 10 vertices for the dimension ∞ under the curvature flow.

**Figure 5.**Curvature flow of a complete graph with six vertices with degenerate initial weighting scheme ${P}_{0}$ (

**left**-hand side) and numerical flow limit $P\left({t}_{\mathrm{max}}\right)$, the simple random walk (

**right**-hand side).

**Figure 6.**Transition rates of vertices ${v}_{2}$ and ${v}_{5}$ of a complete graph with six vertices under the curvature flow.

**Figure 8.**Initial weighting scheme (

**left**) and numerical flow limit a simple random walk on ${K}_{3}$ (

**right**).

**Figure 9.**Initial weighting scheme (

**left**) and numerical flow limit a simple random walk on ${K}_{4}$ (

**right**).

**Figure 10.**Initial weighting scheme (

**left**) and numerical flow limit a simple random walk on ${K}_{5}$ (

**right**).

**Figure 11.**Curvature flow of a dumbbell as a wedge sum of a ${K}_{5}$, ${K}_{2}$ and another ${K}_{5}$ with simple random walk initial weighting scheme ${P}_{0}$ (

**left**-hand side) and numerical flow limit concentrated on ${K}_{2}$ (

**right**-hand side).

**Figure 12.**Left-hand side: An octahedron with vertices ${v}_{0},\dots ,{v}_{5}$. Right-hand side: A numerical flow limit of the octahedron with a small perturbation of simple random walk as initial weighing scheme.

**Table 1.**Vertex curvatures for the dimension ∞ of a random graph with 10 vertices at the beginning and the end of the curvature flow.

j | ${\mathit{K}}_{\mathit{P}\left(0\right),\mathit{\infty}}\left({\mathit{v}}_{\mathit{j}}\right)$ | ${\mathit{K}}_{\mathit{P}\left({\mathit{t}}_{\mathbf{max}}\right),\mathit{\infty}}\left({\mathit{v}}_{\mathit{j}}\right)$ |
---|---|---|

0 | $0.406$ | $0.875$ |

1 | $0.293$ | $0.875$ |

2 | $0.168$ | $0.125$ |

3 | $0.346$ | $0.875$ |

4 | $0.34$ | 0 |

5 | $0.527$ | $0.476$ |

6 | $0.404$ | $0.875$ |

7 | $0.202$ | $0.773$ |

8 | $0.246$ | $0.11$ |

9 | $0.236$ | $0.125$ |

**Table 2.**Statistics of flow limit concentrations on the complete subgraphs ${K}_{4},{K}_{5},{K}_{2}$ and ${K}_{3}$ of their wedge sum, together with mean convergence times.

${\mathit{K}}_{4}$ | ${\mathit{K}}_{5}$ | ${\mathit{K}}_{2}$ | ${\mathit{K}}_{3}$ | |
---|---|---|---|---|

concentration of flow limits | $8.7\%$ | $80.5\%$ | $0\%$ | $10.8\%$ |

mean convergence time | $18.9$ | $24.7$ | – | $17.7$ |

Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |

© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Cushing, D.; Kamtue, S.; Liu, S.; Münch, F.; Peyerimhoff, N.; Snodgrass, B.
Bakry–Émery Curvature Sharpness and Curvature Flow in Finite Weighted Graphs: Implementation. *Axioms* **2023**, *12*, 577.
https://doi.org/10.3390/axioms12060577

**AMA Style**

Cushing D, Kamtue S, Liu S, Münch F, Peyerimhoff N, Snodgrass B.
Bakry–Émery Curvature Sharpness and Curvature Flow in Finite Weighted Graphs: Implementation. *Axioms*. 2023; 12(6):577.
https://doi.org/10.3390/axioms12060577

**Chicago/Turabian Style**

Cushing, David, Supanat Kamtue, Shiping Liu, Florentin Münch, Norbert Peyerimhoff, and Ben Snodgrass.
2023. "Bakry–Émery Curvature Sharpness and Curvature Flow in Finite Weighted Graphs: Implementation" *Axioms* 12, no. 6: 577.
https://doi.org/10.3390/axioms12060577