Hierarchy Depth in Directed Networks

In this study, we explore the depth measures for flow hierarchy in directed networks. Two simple measures are defined—rooted depth and relative depth—and their properties are discussed. The method of loop collapse is introduced, allowing investigation of networks containing directed cycles. The behavior of the two depth measures is investigated in Erdös-Rényi random graphs, directed Barabási-Albert networks, and in Gnutella p2p share network. A clear distinction in the behavior between non-hierarchical and hierarchical networks is found, with random graphs featuring unimodal distribution of depths dependent on arc density, while for hierarchical systems the distributions are similar for different network densities. Relative depth shows the same behavior as existing trophic level measure for tree-like networks, but is only statistically correlated for more complex topologies, including acyclic directed graphs.


Introduction
The concept of hierarchy has been used for systems described with networks for a significant time and for different purposes.It has been considered in context of elections [1], investigation of road network geometry [2] and neural networks [3].More recently, the concept of hierarchy has been used for social systems [4,5,6,7,8], artificial neural networks [9], financial markets [10] and communication networks [11].It has also been used on a more theoretical level, to distinguish and explain specific network properties [12].While the concept of hierarchy has been extensively used, it is continuously lacking a definition.There are papers that attempt to remedy that by introducing more formal definition and measures [13,14,15].The paper by Corominas-Murtra [15] introduces definition of causal graphs and perfect hierarchical structure, and introduces measure of hierarchy that is based on similarity of a given graph to a perfect hierarchy.The paper by Mones et.al. [14] distinguishes between three types of hierarchy: order (as in [4,5,6,7,8]), nested (as in [12]) and flow (as in that paper and [15]).The order hierarchy is a simple ordering of elements of a set along one dimensional axis.The nested hierarchy is tied to the community structure and multi-scale organization of the network.The flow hierarchy is basically a causal structure, with (using tree analogy) the "root" being the origin of all signals or flows, and "leaves" being simply receivers.In this paper, we focus on the flow hierarchy.As pointed out in [14] order hierarchy can be seen as simple flow hierarchy, and nested hierarchy can be represented by a flow hierarchy.In our work, we intend not to make another definition of hierarchy, but to measure a single aspect of it -its depth.We introduce two depth measures for directed networks and discuss their behavior and differences between them.We also show how the existence of cycles can be taken into account and how they influence depth measures.

Definitions of depth
We define depth measures for directed networks, that are composed of vertices connected by arcs (directed edges).In general, they are applicable to any directed network, even if it contains cycles.The depth is defined in the context of flow hierarchies, and is therefore most meaningful for networks that have a certain overall direction of all arcs.
The rooted depth is a value defined for each vertex in a network, and is the distance of that vertex from a root.Use of this definition requires a fixed root vertex.Let us start simple and first consider a tree, where root is well defined.We are considering directed networks and consider tree where arcs are all directed from root and towards leaves.The root is a vertex with only outgoing arcs, while leaves have only incoming arcs.Each vertex i is at certain depth d i in the network, which we define as the distance from root to the vertex l ri .This means that all vertices are organized into distinct depth levels.
Let us now generalize to any graph with a specified root, which we will call rooted network.The root is the only vertex that has only outgoing arcs, and no incoming arcs (k in r = 0).Leaves are vertices without outgoing arcs, but some incoming arcs.The definition remains same without any changes, the distance being the length of shortest path.Because of the existence of multiple paths of different lengths, it is possible however, that an arc connects higher depth vertex with lower depth vertex (Figure 1).Because the definition uses shortest path, it effectively ignores any arcs that are not part of a shortest path.This definition works for networks with loops and effectively ignores them.It is easy to understand, as at least part of the loop has to be not a shortest path from root to somewhere, so it simply is ignored.
Figure 1: Rooted network of 3 depth levels, with root r marked by thick boundary.Vertex i is at depth 2, while vertex j, connected by incoming arc from i is at depth 1, showing that globally defined hierarchy does not necessarily describe local structure.Average depth (calculated for leaves) is 21/3, because leaves are at different depths.The arc from i to j is effectively ignored when depth levels are calculated.The numbers on the right show depth levels.
If we define any vertex that has no incoming arcs as a root, we may treat any directed graph as a sum of several rooted networks (Figure 2).Each root vertex has a part of network reachable form it, forming its own rooted component, which may encompass whole network, but it not necessarily does.Given multiple roots, a given vertex i has several possibly different depths, depending which root we will look at.Reasonable solution is to average the depths from different roots to obtain a single depth value for a vertex.Additional issue comes from fact, that existence of loops means that no roots may exist in the whole network.In such case, the definition does not work, unless we perform loop collapse (see below).
Figure 2: Acyclic directed graph and its rooted depth.White vertices belong only to rooted component of root r1, while dark grey only to component of root r2.Light grey vertices belong to both rooted components.Depth levels of vertices (left for r1, right for r2) may be different relative to each root.Vertex i is at depth 2 from root r1 and at depth 2 from r2 -it is generally not possible to draw the depth levels consistently for rooted depth.Note that the graph does not need to be acyclic for the rooted depth to be defined.
The relative depth is defined as a value d i assigned to each vertex i, such that any arc ij always connects from a vertex with lower depth d i to a vertex with higher depth d j (d i < d j ).This basically means that we treat the arcs as a "has depth lesser than" relation on the set of vertices of the graph, and thus define the depth levels for vertices.Such definition is ambiguous, and to give precise values, we add that the difference must be minimal but at least 1 (d j − d i ≥ 1).Depth values assigned according to such definition correspond to difference between vertex depths of i and j being equal to longest directed path between them, provided such path exists (Figure 3).In absence of the path, the difference can be any value.Note that since the values are derived from relations, there is no set "zero level" and the values can be set relative to an arbitrary reference value.For convenience, it is reasonable to set vertex with least depth to 0, thus recovering non-negative depth levels like in the rooted depth definition.The definition of relative depth sets a strict inequality relations between vertices that have directed paths between them, meaning that they can indirectly interact in some way if the network is treated as a topology of interactions.The definition works only for acyclic graphs.Any directed loop is unresolvable, just like an inequality a > b > c > a does not have any solution.We can extend the definition to graph containing cycles if we force all vertices belonging to a given cycle to have the same depth value.This means each cycle is at fixed depth level, regardless of the directed arcs it contains.This is however a logical rule -if all vertices can influence all other vertices in the set, all should be at same depth.Effectively, from the point of view of the definition, a cycle is a single complex vertex.We define loop collapse to be a process, where all cycles are substituted with a complex single vertices (see Figure 4).Note that the loop collapse is virtual -the vertices are not really collapsed, they are only treated so for the single purpose of assigning the depth level.All vertices that are component of a collapsed loop are assigned same depth.If all loops are collapsed, then we recover a directed acyclic graph, and relative depth definition can be used to calculate depth levels.Note that it is possible to use loop collapse independently from relative depth definition, for example using it alongside rooted depth definition, in which case it changes the depth levels.
Figure 4: The idea of loop-collapse of network -virtual substitution of cycles with single "complex" vertices.Example network is the same as in Figure 3 except single added arc between vertices c3 and c1 (depicted thicker).All vertices marked as c1,c2,c3 and c4 form two non-separated loops, and thus are collapsed into single vertex C.After finding out depth values of collapsed network, vertices c1,c2,c3 and c4 are assigned depth corresponding to vertex C. It is possible to have a loop as a "root" in the full network when using loop-collapse, if all vertices in that loop only have incoming arcs from other vertices in that loop.Note that the relative depth of vertex L and whole network decreases significantly due to introduction of the single c3 − c1 arc.
Both definitions attempt to measure the vertical size of the hierarchy or a directed network.Despite aiming for the same, they significantly differ from each other on several points.//The information reduction is present in both cases.Rooted depth uses only shortest path, which means that it effectively ignores any arcs that are not part of a shortest path, which essentially reduces the whole network to a spanning tree of shortest paths.The relative depth on the other hand effectively ignores arcs that are not part of a longest path.Relative depth definition essentially takes into account only arcs that are part of transitive reduction of a relation defined by arcs (which by definition of relative depth is transitive).All "shortcuts" are ignored, often including the shortest paths.Both definitions are different in the aspect of locality.Rooted depth is defined globally and does not describe the local situation consistently -depth levels viewed from local perspective of single vertex may be completely not related to the graph structure.The only rule is that outgoing arcs of given vertex i always connect to vertices with depth no larger than d i + 1 and incoming arcs are form vertices with depths no smaller than d i − 1.The relation between depth levels does not otherwise reflect arc structure, but the depth level of i accurately describes how close the vertex is to the root.Moreover the root is always at known, fixed depth level 0. On the other hand relative depth is defined locally and as such is relevant to local structure.Arcs always go from lesser to greater depth levels, although the actual values are effect of global topology.The depth values do not reflect how close to the eventual root (the "top") is the vertex.A vertex at depth 1000 could be connected directly from the root.Moreover, the depth of a root is not fixed, and if several roots exist, may be found at any depth.Overall, the rooted depth describes the global position more accurately, but fails locally.The relative depth vice versa.Vulnerability of both definitions are also different.Rooted depth requires existence of root vertices and cannot work without them, while the definition of relative depth doesn't work in presence of directed loops.In both cases the loop collapse allows them to work, but nonexistence of root is rare for a network that would not be almost wholly loop-collapsed into single vertex (at least for random graphs).Both definitions of depth are volatile in regard to addition or removal of arcs.A single removal or addition could change depth levels of significant parts of the whole network.Adding new links can only decrease depth levels for rooted depth, and increase them for relative depth, and vice versa.The rooted depth can take into account the multiple aspects of depth.If multiple roots are present, then the depth levels relative to each root can be treated separately, not averaged into a single number, or alternatively aver-aged with certain weights depending on the root or its rooted component.If the depth is considered in the context of a hierarchy, this can differentiate between positions within different hierarchies.Relative depth cannot distinguish multiple aspects, as it has to be defined with a single number for each vertex.It is however consistent, as that number is relatively well defined, without multiple aspects and issues tied to averaging.
Overall, both definitions have their strong and weak points.As they describe the complex topology by simple numbers, they reduce information in different ways, which yields different properties.The choice of depth measure will therefore depend on the aspects of the system being investigated and what one wishes to describe with it.

Results
We have investigated the depth measure values in directed random networks.We investigated a directed Erdos-Renyi graph, where probability of an arc existing between an ordered pair of vertices ij is constant p = k /N.Opposite arcs (e.g.ij and ji) can exist and their existence is decided independently.Note that the parameter k is a directed degreek = k 0 means that on average vertices have k 0 outgoing arcs as well as k 0 incoming arcs.If we looked at those links as undirected the total degree would be twice as high.
First, we attempt to investigate most general properties of the depth depending on the network parameters.The average depth D is a very simple measure, allowing us to look across different network parameters.We are interested in the total depth of the network however, not necessarily the average value of d over all vertices.Similar to physical depth, being distance from surface to bottom, not some average over a volume, we decide to measure D as average od depth level over leaves in the network.For rooted depth and single-root network, this means where N L is the number of leaves, the sum over i is over all leaves and l ri is the path length from the root r to leaf i.If there is more than one root, the depth level of vertices is average over all roots it has directed paths from, which means where N L is the number of leaves, the sum over i is over all leaves, N Ri is number of roots that have path to leaf i, the sum over r is over all roots that have path to leaf i and l ri is the path length from the root r to leaf i.The averaging od depth level for each vertex makes sense when we are investigating that single vertex.If we are looking at whole network however, it is more reasonable to look at pairs root-leaf and averaging over that.This would yield a definition where N RL is number of pairs root-leaf connected by directed path, the sum is over all pairs r, i that are connected by a path and l ri is the lengh of that path.Equations 2 and 3 define slightly different values.In the first equation, if vertex is under small number of roots, the depth levels generated by them are contributing more to the total compared to a vertex under large number of roots, which averages over more different depths.If all vertices have directed paths from all roots, then both equations are equivalent as 1/N Ri = const.and therefore it can be extracted from under the sum over i and N L N R = N R L is all pairs have paths between them, thus recovering equation 3.As we are calculating a global property, we decided to use the definition described by Equation 3 as more appropriate on the global level.
The dependence of average rooted depth D on average node degree k is shown at Figure 5.Note that in case where no roots or leaves could be found, we assumed depth equal to 0 for practical reasons.
We explain the results at Figure 5 as follows.Below k = 1, the network is not percolated and consist of single vertices (D = 0) and small clusters (responsible for increasing value of D with k ).Loops are very rare.At k = 1 the network becomes percolated (note that this is directed percolation), creating the giant cluster.This corresponds with the maximum of the average depth level.The average depth is tied ot the diameter of the giant cluster as well as the amount of still present disconnected clusters.Above k = 1 adding more arcs means creating loops, since the network is already percolated.Loops introduced randomly cause decrease of the component diameter and thus depth, which corresponds to the first drop of D after the peak.Increasing number of loops also may cause situations where no roots or no leaves exist in the network, causing the average depth to drop towards 0 (the assumed value for network without roots or leaves).This starts to happen only at high k and is responsible for second drop of the H (around k = 6 for N = 1000).Figure 6 shows how example network looks like at different k .It is notable that the shape of the dependence of network depth on density shown on Figure 5 is very similar to Global Reaching Centrality measure introduced by Mones et.al.[14] and calculated for directed random graphs [16].The similarity can be explained, by both depth and GRC being measures for hierarchies.Below percolation threshold, the graph consists of many small clusters, which yield very low average depth, at the same moment giving very low GRC due to narrow Local Reaching Centrality distributions.Significantly above percolation threshold, the presence of many loops mean that the network has large strongly connected component, that has relatively low depth as well as again producing narrow LRC distribution and in effect low GRC.At percolation threshold, the giant connected component is criti-cally sparsely connected, meaning no loops and in effect a high depth (long shortest paths).On other hand, without loops the vertices have a broad distribution of LRC, resulting in high GRC.Both measures achieve high values for a large, extended directed network without loops, which explains the correlation.White vertices are leaves, dark gray are roots and hatched vertices are both leaves and roots (and in general single vertices).At c), the network has a strongly connected "core" that consists of interleaving loops and therefore under loop-collapse rules all have same depth.The roots and leaves are attached to that core.
Because the rooted depth cannot be resolved in case there are no roots or leaves in the network, and also to have better comparison between rooted depth and further relative depth, we decided to also investigate rooted depth while using the loop-collapse.The results are somewhat different and found at Figure 7.The main differenc is the plateau after the peak, with value D = 2.This corresponds to a network with a dense "core" containing many interleaving loops, and thus collapsed to a single complex vertex, with single vertex "roots" and "leaves" sticking out of this core.Without the loopcollapse, the loops were partially converted to "vertical" and assigned some differing depths (differently from perspective of each root), the denser the core, the smaller depths.With loop-collapse, the value of D for network with the dense core is fixed at 2, resulting in plateau.Note that since loopcollapse virtually removes all loops, there are always roots and leaves and in worst case the sole remaining complex vertex is both root and leaf and thus has D = 0. Also note that all the values (D, k , N) are calculated for the real, full network.Loop-collapse is used only to calculate depth levels.The results are similar, although there are differences.Below k = 1, the behavior is the same, as lack of loops means loop-collapse doesn't do anything.After the maximum, the average depth D declines much faster, because addition of loops causes loop-collapse, thus decreasing the effective size of the giant component much quicker.The value then stabilizes at D = 2, because the typical topology of loop-collapsed network at this point consists of single complex network representing the majority of original vertices, with few single roots and leaves directly attached to it.As the k becomes even higher, the network starts to entirely collapse to single complex network, causing D to approach 0 for very high k .This explanation is reinforced by the size of the loop-collapsed network, that is very close to original size below percolation threshold k = 1, and then exponentially decreases towards single vertex (Figure 8).
The measurement of relative depth can be performed similarly.Since we need to use loop-collapse, we always recover roots and leaves.If our relative depth levels are scaled so that the lowest value is 0 (similarly to how roots in rooted depth have depth 0), we can calculate average depth of leaves (the "bottom") and treat that as the depth of the network where d is average over leaves.Note however, that unlike in rooted depth, roots (the "surface") can be at different depth levels themselves.We can thus calculate the depth of whole network as difference between average depth of leaves and roots (the "bottom" and "surface") . The first equation ( 5) describes the depth of the network globally, taking into account the extreme value (for roots).The second equation ( 4) is a more locally relevant, showing what is the likely depth in a part of the network.It could be compared to rooted depth where we only take "highest" root into account and normal rooted depth that considers all roots.Both equations yield similar results, presented in Figure 9.In general, it can be seen that relative depth behaves similarly to rooted depth.For small k the value is low.The peak is around percolation threshold, corresponding to the maximally stretched treelike structure of the giant component, and then the decline of average depth correspond to the gradual increase in density and number of loops, which flattens the network when if comes to depth (remember we use loop-collapse).The one difference between rooted and relative depth discrenible on the plots is the absence of the sudden drop for higher k ≈ 6.This can be explained by the fact, that when we couldn't find either roots or leaves in rooted depth calculation, we assumed total depth equal to 0. If we look at Figure 6, we see that in the "core with roots and leaves" stadium, loss of last root effectively makes the value 0 (the assumed value), despite one arc earlier having depth 2 or even more.This accounts for the fast drop of depth for rooted depth not using loop-collapse.Since relative depth always uses loop collapse, the "core with roots and leaves" would simply change into depth 1 structure, where either the "core" would assume role of leaf/leaves (loss of last leaf) or role of root (loss of last root).The transition is smooth, thus no sudden drops on the graphs for relative depth could be found.Both plots are essentially the same, with small differences in heights.
Trying to describe the behavior of the depth measures for different network parameters we also investigated the height of the D peak for different network sizes and different definitions.Figure 10 shows results for rooted depth of networks without loop-collapse, with loop-collapse and for relative depth.We found power dependence od rooted depth on size, with exponent ≈ 0.3 to ≈ 0.4).We expect these values to be related to the diameter (maximum shortest path length) of the percolation cluster in random graph.The relative depth peaks also behave as a power of network size, albeit with significantly lower exponent ≈ 0.2.

Conclusions
We have defined two depth measures for flow hierarchies, generalized to any type of directed network.Rooted depth is defined as shortest path from one of network's roots, while relative depth is defined through relations between vertices and is effectively equal the longest path from the root.The differences between these measures are discussed -rooted depth ignores arcs that are not shortest paths, while relative depth ignores arcs that are not longest paths.Rooted depth has more global meaning, while relative one is more meaningful locally.We have investigated the two measures on a random Erdos-Renyi networks, showing how they behave on purely random network, thus allowing better understanding of values obtained in other types of networks.Both measures behave similarly to a Global Reaching Centrality measure of how hierarchical the network is.

Figure 3 :
Figure 3: Acyclic directed graph and its relative depth.The graph is the same as at Figure 2, except the layout being adapted to relative depth values.Note vertex i is at high depth 5 despite being only 2 arcs away from the depth 0. Two roots present in the graph, r1 and r2 are found at depths 0 and 3.All arcs always point downwards, by definition of relative depth.

Figure 5 :
Figure 5: Dependence of average rooted depth of directed ER graph on average directed degree for different network sizes.

Figure 6 :
Figure 6: The example topology of random network at different arc densities k and its relation to the depth values.a) for low density k < 1, b) at percolation threshold k = 1, c) for high density k > 1.White vertices are leaves, dark gray are roots and hatched vertices are both leaves and roots (and in general single vertices).At c), the network has a strongly connected "core" that consists of interleaving loops and therefore under loop-collapse rules all have same depth.The roots and leaves are attached to that core.

Figure 7 :
Figure 7: Dependence of average rooted depth of loop-collapsed directed ER graph on average degree for different network sizes.Note that all the values are for the real, full network, not loop-collapsed one.

Figure 8 :
Figure 8: Dependence of size of loop-collapsed directed ER graph on original average (in/out, not total) degree for different original network sizes.

Figure 9 :
Figure9: Dependence of average relative depth of loop-collapsed directed ER graph on average degree for different network sizes, computed as difference between leaf and root average depths (Rq.5).Inset: Plot for relative depth scaled to 0 for lowest-depth root.Both plots are essentially the same, with small differences in heights.

Figure 10 :
Figure 10: Dependence depth peak heights for ER graphs on the graph size.The three series are rooted depth without loop-collapse, with loop-collapse and relative depth peak heights.The height of the peak was measured from a series of D( k ) with 0.1 resolution on the k axis.