igraph-help
[Top][All Lists]

## Re: [igraph] Measuring the density of indepenent layers in a multilayere

 From: Tamas Nepusz Subject: Re: [igraph] Measuring the density of indepenent layers in a multilayered network Date: Fri, 7 Oct 2016 23:01:52 +0200

Hello,

The easiest (and probably not the most efficient) way is to take the
induced subgraph of all the vertices in a layer and then call
density() on the induced subgraph.

However, if you want the density of all the layers at once, there is a
better option:

1. Take the edge list of the graph
2. Re-map each vertex index in the edge list to its layer index
3. Create a table where the i-th row and the j-th column contains the
number of edges between layers i and j
4. Take the diagonal of the table
5. Count how many vertices there are in each of the layers
6. Count how many edges there could be in each of the layers if the
layer was completely full
7. Divide the vector in step 4 by the vector in step 6, elementwise.

E.g. (in R):

> g <- grg.game(100, 0.2)
> V(g)\$layer <- sample.int(5, vcount(g), replace=T)
> layers_of_edges <- matrix(V(g)\$layer[get.edgelist(g)], ncol=2, byrow=F)
> edge_counts_in_layers <- diag(table(layers_of_edges[,1], layers_of_edges[,2]))
> layer_sizes <- table(V(g)\$layer)
> edge_counts_in_layers / (layer_sizes * (layer_sizes-1) / 2)

T.

On Fri, Oct 7, 2016 at 10:27 PM, Ahmed Abdeen Hamed
> Hello friends,
>
> In a multilayered network, would it be possible to measure the density of
> the independent layers? Layers are identified by a label so it can be
> retrieved from the main graph. Please feel free to share with me some code
> examples.
>
> Thanks so much and have a great weekend,
>
> -Ahmed
>
> _______________________________________________
> igraph-help mailing list