Ollivier Ricci curvature of directed hypergraphs

Many empirical networks incorporate higher order relations between elements and therefore are naturally modelled as, possibly directed and/or weighted, hypergraphs, rather than merely as graphs. In order to develop a systematic tool for the statistical analysis of such hypergraph, we propose a general definition of Ricci curvature on directed hypergraphs and explore the consequences of that definition. The definition generalizes Ollivier’s definition for graphs. It involves a carefully designed optimal transport problem between sets of vertices. While the definition looks somewhat complex, in the end we shall be able to express our curvature in a very simple formula, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\kappa =\mu _0-\mu _2-2\mu _3$$\end{document}κ=μ0-μ2-2μ3. This formula simply counts the fraction of vertices that have to be moved by distances 0, 2 or 3 in an optimal transport plan. We can then characterize various classes of hypergraphs by their curvature.

for instance 7 as a reference), the curvature of a space quantifies its non-flatness. Among the various curvature notions that are of importance in Riemannian geometry, Ricci curvature quantifies this deviation by comparing the average distance between two sufficiently close points and the distance between two small balls around them. Bounds on curvatures can be used to connect the geometry of a Riemannian manifold with its topology, or to control stochastic processes on it. More precisely, a positive lower bound for the Ricci curvature yields the Bonnet-Myers theorem, which bounds the diameter of the space in terms of such a lower Ricci bound, the Lichnerowicz theorem for the spectral gap of the Laplacian, a control on mixing properties of Brownian motion and the Levy-Gromov theorem for isoperimetric inequalities and concentration of measures. In view of these strong implications, it is desirable to extend this to metric spaces that are more general than Riemannian manifolds. With this motivation, several generalized curvature notions have been proposed for non-smooth or discrete structures. In particular, Ollivier 12 defined a notion of Ricci curvature on metric spaces equipped with a Markov chain, and extended some of the mentioned results for positively curved manifolds. His definition compares the Wasserstein distance between probability measures supported in the neighborhoods of two given points with the distance between these points. The Wasserstein distance between two probability measures is defined as the minimal cost needed for transporting one into the other. That is, an optimal transport problem has to be solved. On Riemannian manifolds, this recovers the original notion of Ricci curvature (up to some scaling factor), and at the same time, it naturally applies to discrete metric spaces like graphs. Recently, this curvature has been applied in network analysis, to determine spreading or local clustering in networks modelled by undirected or directed graphs, see for instance 14 . It is therefore desirable to have such a tool also for hypergraphs. In this paper, we shall develop a notion of an Ollivier-type Ricci curvature for, possibly directed and/or weighted, hypergraphs. There have been some prior proposals for extensions of Ollivier-Ricci curvature in such a direction (see for instance 1,2,15 ), but our approach is more general and, as we argue, also more natural both in terms of its conceptual motivation and its range of applicability to empirical networks. From a geometric perspective, the fundamental principle that curvature characterizes types of spaces also applies here as we can distinguish and classify particular classes of directed hypergraphs in terms of their curvature. A definion of the Ollivier Ricci curvature of directed graphs was firstly proposed and investigated in 15 where out-out directions for assigning measures are used. For that, however, one needs to assume strong connectivity of the underlying directed graphs in order to find transportation plans with finite cost, but this does not hold in many real directed networks. Therefore, in this paper, we work with in-out directions, which does not require such a strong assumption. The resulting theory is rather different from that of 15 . The first extension of the notion of Ollivier Ricci curvature to hypergraphs was proposed in 1 , using a multi-marginal optimal transport problem to define curvature. Because of that, the resulting curvature in the end is an analogue of Riemannian scalar rather than Ricci curvature. Also, it does not directly apply to directed hypergraphs. In this paper, we therefore propose a notion of directed hypergraph curvature that extends Ricci curvature rather than scalar curvature. Since in our setting, hyperedges are directed and each direction separates the vertices of the hyperedge into two classes, similar to directed graphs, we consider a double marginal optimal transport problem. We study some implications of our definition and then take a closer look at hypergraphs of constant Ricci curvature. In 9 , our notion of Ricci curvature for hypergraphs is systematically applied to empirical networks, leading to insight not readily available through other methods of network analysis.
Ricci curvature. In order to proceed, we first need to explain the geometric meaning of Ricci curvature.
Ricci curvature is a fundamental concept from Riemannian Geometry (see for instance 7 ) that more recently has been extended to a discrete setting.
For a Riemannian manifold M of dimension N, Ricci curvature can be defined in several equivalent ways. What is relevant for the extension to the discrete setting is that it measures the local amount of non-flatness of the manifold by comparing the distance between two small balls with the distance of their centers when these centers are sufficiently close to each other. To be more precise, consider a unit tangent vector w at a point x in a Riemannian manifold M and let ε, δ > 0 be smaller than the injectivity radius of M. Suppose exp x (.) : T x M −→ M denotes the exponential map and y is the endpoint of exp x δw and hence at distance δ from x. Let S x be the sphere of radius ε in the tangent space at x (and hence exp x S x is the sphere of radius ε around x in the manifold). Then if S x is mapped to S y using parallel transport, the average distance between a point of exp x S x and its image in exp y S y is when (ε, δ) → 0 . If balls are used instead of spheres, the scaling factor is ε 2 2(N+2) instead of ε 2 2N 13 . This follows from standard Jacobi field estimates. These estimates involve the sectional curvature, but summing over all directions orthogonal to the geodesic connecting x and y results in a Ricci curvature term. Here, one should think of ε as being smaller than δ , and O(ε 3 ) then simply indicates a higher term, whereas O(ε 2 δ) is needed when the Ricci curvature is not constant. In Riemannian geometry, one can then average the Ricci curvatures of the directions at a point. This then yields the scalar curvature, which thus is a quantity naturally associated to points. The scalar www.nature.com/scientificreports/ curvature is a much weaker geometric invariant than the Ricci curvature. Returning to the latter, if balls in average are closer than their centers (Fig. 1a), Ricci curvature in the direction of xy is positive. If the manifold is locally flat, Euclidian (Fig. 1b), then the two distances coincide. Most manifolds, however, are locally negatively curved (Fig. 1c) 10 . This local characterization is the key property for defining Ricci curvature notions in more general settings than smooth manifolds. In 2007, Ollivier defined a notion of Ricci curvature, called Ollivier (coarse) Ricci curvature, on metric spaces equipped with a random walk m; Recall that if (X, d) is a Polish metric space equipped with its Borel σ-algebra, a random walk m on X is a family of probability measures {m x |x ∈ X} satisfying the following conditions 12 : • The map x → m x is measurable.
• Each m x has finite first moment, i.e., for some (hence any) z ∈ X one has d(z, y)dm x (y) < ∞.
Also in the following definition, we let d(x, y) be the distance from x to y obtained from the metric. Definition 1.1 12 Let (X, d) be a metric space with a random walk m, let x, y ∈ X be two distinct points. The Ricci curvature of (X, d, m) in the direction (x, y) is where W 1 is the 1− Wasserstein distance between m x and m y on X: where �(m x , m y ) is the set of measures on X × X whose first (second) marginal is m x ( m y ) (thus, each E(x, y) is a coupling between random walks projecting to m x and m y ).
Here instead of taking metric balls around two close enough points we consider the Wasserstein distance (Transportation or Earthmover distance), between two probability measures m x and m y corresponding to two random walks which are starting at x and y respectively. When (X, d, m) is Riemannian manifold equipped with Riemannian volume measure, as it is shown in 12 , this notion coincides with the Riemannian Ricci curvature in the direction of xy (up to some scaling factor).
In network analysis, and particularly for networks that are modeled by undirected graphs, this notion has proved itself as a very useful tool to determine clustering and coherence in the network 8,14 , and since it is based on Markov chains, it is very well suited for capturing diffusion and stochastic processes in the network. One can see this as a motivation for the definition of 1 where multi-marginal optimal transport was used to define a notion of curvature for collections of points in metric spaces. Since this is defined for points rather than for directions, from our perspective, this should be considered as a version of scalar curvature, rather than of Ricci curvature. However, the definition we shall present in the next section will be different.

Results
Transport plans and curvature of directed hypergraphs. As already mentioned, similar to directed graphs, in directed hypergraphs, every hyperedge e in E represents a directional relation between two nonempty subsets A e (tail), B e (head) of the vertex set V. In this paper we often write A instead of A e , and B instead of B e when the hyperedge e is specified and fixed. Note that the sets A e , B e and V can be equal, namely when the hypergraph has just one hyperedge e and its tail set and head set coincide. However if for a hyperedge e, A e or B e is a proper subset of V, then since we consider non-empty subsets of V, the other one should also be proper. Similarly, for any vertex x ∈ V , d in x is the number of incoming hyperedges to x (those hyperedges which include x in their head set), and d out x is the number of outgoing hyperedges from x (those hyperedges which have x in their tail set). Also a directed path between the vertices in a directed hypergraph G is an alternating sequence of www.nature.com/scientificreports/ distinct vertices and directed hyperedges (v 1 , e 1 , . . . , v k , e k , v k+1 ) such that for each i, v i and v i+1 are in the tail and head sets of e i respectively. If k ≥ 1 and v 1 and v k+1 are the same vertices, the path is called a directed k-cycle. From now on we consider directed hypergraphs to be weakly connected, meaning that the underling undirected hypergraph is connected.
be an unweighted directed hypergraph and e ∈ E be an arbitrary directed hyperedge such that A = {x 1 , . . . , x n } e − → B = {y 1 , . . . , y m } (n, m ≤ |V |) . We define the Ollivier-Ricci curvature of this hyperedge as where the probability measures µ A in (called mass) and µ B out (called hole), are defined on V as follows: and likewise and W(µ A in , µ B out ) is the 1− Wasserstein distance between these two discrete measures defined as follows: where d(u, v) is the length of a shortest path from u to v and for a transport plan E , E(u, v) represents the amount of mass moved from vertex u to vertex v and �(µ A in , µ B out ) is the set of transport plans, that is, probability measures on V × V that have µ A in and µ B out as their marginals. In other words, the minimum is taken over all couplings E between µ A in and µ B out which satisfy

Remark 2.1
Since we are working with directed objects, in this definition we had to provide for the situation where a vertex in the tail does not have incoming connections, or where a vertex in the head does not have any outgoing ones. In undirected networks, this is not an issue, because then the hyperedge in question itself provides both.
We can construct for each directed hypergraph a corresponding directed graph. That graph has the same set of vertices as the directed hypergraph and for each hyperedge, we draw an edge from each vertex in its tail to every vertex in its head. Thus, a directed hyperedge A = {x 1 , . . . , x n } e − → B = {y 1 , . . . , y m } corresponds to a set with nm elements of directed edges. Note, however, that there might be directed graphs that correspond to more than one directed hypergraph. Proof Let E ij be the optimal transport plan for the edge e ij : www.nature.com/scientificreports/ Then has the marginal distributions µ A in and µ B out . Therefore: However, the corresponding directed edges of a directed hyperedge do not fully represent the geometric structure of that hyperedge as shown in the following.

Remark 2.2
The maximum of the Ricci curvatures of directed edges corresponding to a directed hyperedge is not necessarily an upper bound for its Ricci curvature, as one can see from the example where the curvature of the hyperedge with red colour is one and the curvature of all its four corresponding directed edges is −1/2 .
Proof The proof is similar to the proof of proposition 2.10 in 15 where another measure (out-out) for defining Ricci curvature of a directed edge is considered. Here we show that the same result holds for directed hypergraphs by assuming other directions (in-out) for defining measures. We have: thus: and since for all Lipschitz functions on hypergraphs this inequality holds and the left hand side is independent of f, we obtain

Remark 2.3
In general, we do not get equality in this lemma; equality holds for undirected hypergraphs (see 15 ), or more generally, if for every directed hyperedge e from A e to B e , we have a directed hyperedge e ′ in the reverse direction, from B e to A e (i.e, A e ′ = B e , B e ′ = A e ). In that case, all distances d(u, v) become symmetric. www.nature.com/scientificreports/ We now propose another formula for the curvature of a hyperedge which is more intuitive and in some cases much easier to work with.
For defining the Ricci curvature of a hyperedge e, we use incoming hyperedges to its tail set ( A e ) and outgoing hyperedges from its head set ( B e ). If u and v are in the support of µ A in and µ B out respectively, then d(u, v) ≤ 3 . Recall that for any real valued function f on V, the support of f (denoted by suppf) is the set of all vertices in V where f is non-zero, i.e., If µ i is the amount of mass that is moved with distance i(i ≤ 3) in an optimal transport plan, then we have: If κ = 0 then W = 1 , and we thus have µ 0 = µ 2 + 2µ 3 . More generally, we obtain

Theorem 2.1 The curvature of a hyperedge is given by
In fact, we could simply use (2) as a definition of Ricci curvature.The formula (2) for the curvature of a directed hyperedge, also works for curvature of edges in undirected graphs. As in the (undirected) graph case, µ 0 represents the amount of mass which is not moved in an optimal plan, i.e., the amount of the stable mass in directed 3-cycles (u → x i → y j → u) (where u is simultaneously in the support of µ A in and µ B out ) or directed loops emerging from any of the x i s. Although µ 1 (the mass moved with distance one, possibly through directed quadrangles (u → x i → y j → v, while u is directly connected to v, u → v ) does not appear in the formula for the curvature, computing µ 1 is an intermediate step for the computations of µ 2 and µ 3 where µ 2 is the amount of mass that should be moved with distance 2 (possibly through directed pentagons including x i and y j ) and µ 3 is the amount of the mass that is moved with distance 3 in an optimal plan.

Remark 2.4
While finding the general formula for µ 1 (and µ 2 ) may be difficult, any lower bound for µ 1 (after simply knowing the exact amount of µ 0 ) helps us to derive some upper bounds for W and therefore a lower bound for the curvature. Also the µ i can differ between different optimal transport plans, but equalities (1) and (2) will always hold.
We also point out that while optimal transport plans always exist in our finite setting, they need not be unique.
As an example, in Fig. 2, for computing the curvature of the green hyperedge which connects three vertices in its left(A) to two vertices in its right(B), separated by dots, we assign masses (red bullets) and holes (empty squares) respectively to the incoming neighbours of A and outgoing neighbours of B. Note that since for a vertex x in A (the lowest vertex in A), d in x = 0 , we put all its assigned mass at x which is equal to 1/3. Similarly there is a vertex y in B such that d out y = 0 . Therefore we put its whole assigned measure at y itself and it is equal to 1/2. Also for the other vertices in A (respectively B), their assigned masses (holes) are divided between the vertices in the tails of incoming hyperedges to A (the vertices in the heads of outgoing hyperedges from B) based on Definition 2.1. It is straightforward to check that in (any) optimal transport plan, 1/12 of the mass need not be moved. This is the amount of the mass which coincides with one of the holes. Also 1/3 of the mass at x is moved with distance one to the hole at y. 1/6 is moved with distance two and the remained part is moved with distance three. Hence the curvature of the green hyperedge is −11/12. Bounds for the curvature. For obtaining an upper bound for the curvature of a hyperedge we need to control µ 0 which corresponds to the stable mass at directed 3 cycles (triangles in the undirected graph case) and those vertices which are in the intersection of A and B.
In what follows, we shall see that increasing the number of vertices in this intersection will make the curvature more positive. Here, a directed hyperloop is a directed hyperedge e : A = {x 1 , . . . , x n } → B = {y 1 , . . . , y m } for which A ∩ B is non-empty. Specifically where A ∩ B = A = B , we shall have κ(e) = 1 . Directed k-cycles where k ≥ 4 do not affect the curvature of directed hyperedges since they can not make short-cuts for moving any of the masses to any of the holes. Also the equality holds when for a hyperedge e, all the masses coincide with all the holes with the same size. For instance in directed hyperloops when A ∩ B = A = B both sides of the above formula are equal to one. As another general example see Lemma 2.2. www.nature.com/scientificreports/ As already mentioned in Remark 2.4 after computing µ 0 , any non-zero amount for µ 1 would give us an upper bound for W. For that, at least one incoming neighbour of A should be at distance one from some outgoing neighbour of B. For example, when for the hyperedge e, e : A = {x 1 , . . . , x n } → B = {y 1 , . . . , y m } , there is at least one hyperedge e ′ from any y j to any x i (e ′ : y j → x i ) or/ and when there is at least one x i with d in x i = 0 and at least one y j with d out y j = 0 , the required condition is sattisfied and there is at least one mass which is in distance one from at least one hole and therefore we can present a transfer plan (similar to that in Theorem 3 in 8 ) to obtain a positive lower bound for µ 1 . Specifically, in the same way that trees reach the smallest possible amount of curvature in undirected graphs, here hyperedges in directed hypertrees get the lowest possible number.

Definition 2.2 A directed loopless hypergraph is a hypertree if
(1) There is at most one directed path between any two vertices and (2) It does not contain any directed cycle.
We note that although these two conditions are equivalent in undirected (hyper)graphs, they do not coincide in the directed case. Proof Note that since e is in a hypertree, according to the definition µ 0 = 0 . Hence in a hypertree, the curvature of any hyperedge is non-positive ( κ(e) ≤ 0 ). We shall propose a transfer plan, which gives us an upper bound for W, and we will obtain a lower bound for W based on a single Lipschitz function (defined on the support of µ A in and µ B out ). We shall see that these two bounds coincide. First we move k n ∧ k ′ m of the mass from k x i 's to k ′ y j 's with distance one. Then if k n ≥ k ′ m we move k n − k ′ m of the mass from x i 's with no incoming hyperedges to outgoing neighbours of the y j 's with distance 2 and if k ′ m > k n we move k ′ m − k n of the mass at incoming neighbours of x i 's to those y j 's with no outgoing hyperedges with distance 2. Then we move the remaining part of the mass with distant 3. Therefore W ≤ 3 − k n − k ′ m . On the other hand, for all z in V(H) we define It is straightforward to check that f is a Lipschitz function on A ∪ B ∪ suppµ A in ∪ suppµ B out , hence according to the Theorem 3.5, we have and κ(e) = −2 + k n + k ′ m . www.nature.com/scientificreports/ Extension and reduction.
• Removing vertices from a hyperedge (Reduction) In this part we want to investigate what happens to the curvature of an edge e : A = {x 1 , . . . , x n } → B = {y 1 , . . . , y m } if we remove a number (l, l ′ ) of vertices from A (l ≤ n) and/or from B (l ′ ≤ m) . Curvature depends on the connections between elements of supp µ A in and supp µ B out and removing different vertices from A(and/orB) might have different effects on the curvature. However since the amount of the masses (size of holes) which is assigned to any x i (and y j ) is already determined and is equal to respectively 1/n (and 1/m), we can give a bound for such changes. 1. If the whole mass which is assigned to x i is in directed loops or directed 3-cycles including x i and any of y j s, and after removing x i , its corresponding mass has to be moved with distance 3 in an optimal plan, then 2. If the whole mass around x i was transported with distance 3 in an optimal plan and after removing this vertex, the corresponding mass is in the place of directed loops or directed 3-cycles including vertices of A − {x i } and B, then Therefore we have The same argument works for removing l vertices from A and the proof is complete.
Analogously, by removing l ′ vertices from B (l ′ < m) and using the same argument as before for the holes assigned to B, we have Therefore:  www.nature.com/scientificreports/ Proof Here, since to each x i in A ′ we assign 1 l+n of the total mass (= 1) and 1 l ′ +m of the total hole (= 1) is assigned to each y j in B ′ , by considering the two extreme scenarios as before we have: and therefore: and according to the formula 2 the proof is complete. where E 2 and E 3 represent collections of directed hyperedges. Now, if there is no outgoing hyperedge from C 1 other than elements in E 3 and there is no incoming hyperedge to C 1 other than elements of E 2 and there is no outgoing hyperedge other than e 1 from A 1 and there is no incoming hyperedge to B 1 other than e 1 , then A 1 , B 1 and C 1 would be the desired partitioning set; Since the hypergraph is loopless, the intersection of any two of these sets is empty and because it is weakly connected the union of the vertices is the whole vertex set, V(H). If any of the above conditions does not hold, we can extend A 1 and/or B 1 and/or C 1 as follows: For instance, let there be at least one hyperedge going out of A 1 other than e 1 ; we call it e OA 1 : A 1 → B 11 and we put B 2 = B 1 ∪ B 11 where B 1 and B 11 are not necessarily disjoint. Since κ(e OA 1 ) = 1 , so C 2 := supp µ B out 11 = supp µ A in 1 ⊇ C 1 . We next consider edges in E 3 ; If any of them has an endpoint outside A 1 and if the set of endpoints of E 3 is denoted by A 2 , then A 1 ⊆ A 2 . By repeating this process we obtain an increasing www.nature.com/scientificreports/ sequence of A i 's, B j 's and C k 's. We put A = ∪A i , B = ∪B j and C = ∪C k . Obviously, based on the process, elements in A are connected to B, B to C and C to A and these 3 sets are our desired partitioning.
Remark 2. 6 The converse of this theorem is not necessarily true. For instance, the following hypergraph is not Ricci 1 although there is such a partitioning for the set of vertices of this hypergraph: Instead we have the following: Before proving this Proposition we state the next Lemma.

Lemma 2.2 A directed (loopless) graph is Ricci 1 iff it's set of vertices can be partitioned into 3 sets A, B, C such that A → B → C → A and all the vertices in A are connected to all the vertices in B and similarly for the other arrows, as in the digram in previous theorem.
Proof ⇒ The proof is similar to that of Theorem 2.3. Here, in addition all the vertices of A should be connected to all the vertices of B and so on. The reason is that here, for every edge e : x → y , d in x = d out y , and the condition that supp µ in x = supp µ out y implies that the tails of incoming edges to x coincide with the heads of outgoing edges from y. Hence in the resulted partition every vertex in A is connected to every vertex in B and similarly for the connections between other sets the same situation holds.
⇐ For proving that every edge has curvature 1, for every edge e : x → y , we should have d in x = d out y and supp µ in x = supp µ out y and for every z in this support µ in x (z) = µ out y (z) . Since in the partition all the vertices in A are connected to all the vertices of B and so on, for every edge the needed conditions obviously hold and the directed graph is Ricci 1.

Proof of Proposition 2.6
Since we have such a partition for the vertices of the corresponding directed graph of this hypergraph, according to the previous Lemma, the curvature of all the corresponding edges of each directed hyperedge is 1. Therefore their minimum also has curvature 1. On the other hand, according to Proposition 2.1 So for all hyperedges e, κ(e) = 1 and the hypergraph is Ricci 1.

Remark 2.7
It might be possible that the directed hypergraph is Ricci 1, but as shown in the following example, its corresponding directed graph is not. κ(every hyperedge) ≥ min κ(edges in the corresponding directed graph) Proof Based on the construction, for the two set partitioning, for every hyperedge, the masses are in the source set (A) which is at distance one from the holes which are in the sink set (B). So µ 1 is equal to 1 and the hypergraph is Ricci flat . For the other case, since we are assuming that all the vertices of A are connected to all the vertices of B and similarly for other connections the same condition holds, for every hyperedge e : A → B , the distance between any incoming neighbour of A to any outgoing neighbour of B is one. So µ 1 is equal to 1 (and obviously by construction µ 0 = 0 ). Therefore the hypergraph is Ricci flat .

Remark 2.8
The converse of the previous theorem is not necessarily true. However, If in a Ricci flat directed hypergraph for every directed hyperedge e there is no incoming hyperedge to its tail set and there is no outgoing hyperedge from its head set, then the set of vertices in this directed hypergraph can be partitioned into two sets A and B as above. That is because we can put all the tail sets of all of directed hyperedges in set A and all the head sets of all of directed hyperedges in set B.
In the above theorem, for 3-set partitioning, in contrast to the 2-set partitioning, the sets are partitioned into source, saddle and sink sets. The vertices in a saddle have both incoming and outgoing hyperedges. Also similar to the Ricci 1 case, connections inside any of these three sets might violate constant curvature along different hyperedges. As the last case, in the following part we introduce a class of directed hypergraphs with the most negative curvature. www.nature.com/scientificreports/ Proof Here for every hyperedge e : A → B , the distance between any incoming neighbour of A to any outgoing neighbour of B is 3. Therefore all µ i = 0 , except µ 3 = 1 , and every hyperedge has curvature −2 .
Weighted directed hypergraphs. We can extend our constructions to weighted directed hypergraphs where the vertices and hyperedges may both carry weights. The vertices may carry different weights depending on the hyperedges they are involved in (This can be represented by a vector of the dimension of the hyperedge set with non-negative components. Here, zero means the corresponding hyperedge does not involve that vertex). For a specified hyperedge whose curvature we want to measure, the weights of its vertices need to be fixed, of course. In this case we denote the vertex and hyperedge weights by w v and w e , respectively Similarly, µ B out = m j=1 µ out y j , ∀1 ≤ j ≤ m, z ∈ V (H)

Remark 2.9
In weighted directed graphs, the Proposition 2.6 does not hold because, due to the weights we might have masses which coincide with holes of different sizes and therefore it violates Ricci 1 condition. For instance if we consider two directed 3-cycles which have one edge in common, by considering non-equal weights assigned to two other edges in the two cycles, the curvature of the common edge is not one although we have a three set partitioning in which all the required connections exist. www.nature.com/scientificreports/ • The curvature of a directed (hyper)graph might be rather different from that of the underlying undirected (hyper)graph. For instance, in an undirected graph, every edge in a quadrangle has curvature zero. But a directed k-cycle where k ≥ 4 is negatively curved. • Directed triangles; For undirected graphs, it has been proven that the local clustering coefficient at each vertex can control the scalar curvature of any vertex which by definition is obtained by averaging over the Ricci curvature of all the edges connecting to that vertex (see Corollary 1 in 8 ). In the undirected graph case, the local clustering coefficient is based on the number of triangles containing that vertex and its neighbours. In the directed case, after fixing the direction of every hyperedge, we encounter with four different types of triangles, bounded by only three edges, which share the property of having a directed edge that goes out from A and enters into the set B. Therefore in contrast to the undirected graph case, not all directed triangles but only some of them affect the curvature; in fact, for µ 0 the presence of directed 3-cycles containing the vertices of A and B and of vertices u where u → x i → y j → u, u ∈ A in (u → A) and u ∈ B out (B → u) increases the curvature of the corresponding hyperedge since they directly increase the amount of µ 0 . In contrast, those directed triangles which contain vertices of A and B and u in such a way that x i → u, x i → y j → u, u ∈ A out (A → u) and u ∈ B out (B → u) and those containing A and B and u such that u → x i → y j , u → y j , u ∈ A in (u → A), u ∈ B in (u → B) might affect on the amount of µ 2 and thereby can make the curvature less negative. The last type of directed triangles are those which include vertices of A and B, outgoing vertices of A and incoming vertices to the set B, but they do not affect any of the µ i s and therefore the curvature. For instance in the directed graph depicted in Fig. 3, for computing the curvature of the green edge, the triangle consisting of the red and green edges affects µ 0 . Both triangles including orange-green and blue-green edges have an effect on µ 2 and the curvature is not affected by the presence of the triangle of the pink-green edges.

conclusion
In contrast to ordinary graphs, hypergraphs can faithfully model higher order interactions between data points. Therefore, in empirical network science, nowadays graph representations gradually give way to hypergraphs. Under the label of Petri nets, directed hypergraphs have played an important role in computer science, but with an emphasis rather on processing schemes than on network properties. As systems get larger, however, network aspects are gaining importance 5 . Similarly, with the availability of large scale data sets, hypergraph methods are currently actively developed for the investigation of chemical reaction systems. Since we believe that instead of ad hoc schemes, one should rather develop a systematic mathematical theory, here we generalize concepts and constructions from Riemannian and metric geometry in order to provide such a theory. In particular, we have found that a version of the fundamental notion of Ricci curvature seems a natural tool to probe the local geometry of hypergraphs. Like the Ollivier Ricci curvature in graph theory, this curvature is defined in terms of optimal transport problem between probability distributions assigned to sets of vertices. Our notion can be used to differentiate between positively curved, flat and negatively curved hypergraphs. Consequently, in 9 , applying this tool to metabolic networks we have been able to identify patterns in these networks that can clearly distinguish them from random models that have been proposed as universal models in the literature. Thus, in this paper we demonstrate that a concept inspired from pure mathematics can be fashioned into a novel tool in applied mathematics for analysing systems of interacting elements.