Home > Ideas, Thoughts, What Matt Says, What Pádraig Says > Measuring Hierarchy

## Measuring Hierarchy

Pádraig and I discussed a mechanism for measuring hierarchy, to give a given structure a metric. Pádraig’s suggestion was to measure the average distance to the root, and I came up with a normalised version that should also take into account the relative size of a node (in this case a community), as follows:

The root is always assumed to be a node with a weight of exactly the total size. e.g. for community hierarchy, the size of the node represents the number of members of the community. The root node in this instance contains all members of of the network.

We measure the distance from the root to each community, and multiply the size of the community by the distance. We divide the sum of these values by the size of the root community. If the results is 1, then the community structure is shallow, if the result it less than 1, then the community structure does not contain all nodes, the further the result is upwards of 1 the more depth the structure has.

```\$depth_sum = 0; \$levels = array(); foreach(\$data as \$commid=&gt;\$commdata){ \$levels[\$commdata['level']] +=1; \$depth_sum += ((\$commdata['level'] + 1) * count(\$commdata['members'])); } \$depth_metric = \$depth_sum / count(\$nodes);```

It still needs something to balance for breadth, so,

At each level of the dendogram, we take the size of each node, multiply it by the number of nodes at this level, and divide by the size of the root node, then multiply by the depth. The sum of the results for each node divided by the size of the root node gives us the breadth metric.

```\$breadth_sum = 0; foreach(\$data as \$commid=&gt;\$commdata){ \$breadth_sum += ( (\$commdata['level']+1) * ( (\$levels[\$commdata['level']] * count(\$commdata['members'])) / count(\$nodes) ) ); } \$breadth_metric = \$breadth_sum / count(\$nodes);```

Average Overlap is simply the sum of the number of communities each node is a member of divided by the number of communities.

It will be interesting to calculate these metrics for each dataset and each threshold value, we can plot the delivery ratio (and other metrics)  in a scatter plot for breadth and depth, and see if there is a trend.

Categories: