
From:  Ahmed Abdeen Hamed 
Subject:  Re: [igraph] Measuring the density of indepenent layers in a multilayered network 
Date:  Mon, 10 Oct 2016 15:21:58 0400 
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. Remap each vertex index in the edge list to its layer index
3. Create a table where the ith row and the jth 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_sizes1) / 2)
T.
> ______________________________
On Fri, Oct 7, 2016 at 10:27 PM, Ahmed Abdeen Hamed
<address@hidden> wrote:
> 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
>
_________________
> igraphhelp mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraphhelp
>
[Prev in Thread]  Current Thread  [Next in Thread] 