ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Centralities for undirected networks


Enviado por   •  19 de Noviembre de 2022  •  Apuntes  •  6.785 Palabras (28 Páginas)  •  30 Visitas

Página 1 de 28

Centralities for undirected networks

We shall compute several centrality indices on the Florentine families wedding network. For obvious reasons, we shall only consider the giant component.

library(network)

library(igraph)

library(centiserve)

library(sna)

library(printr)

We define the corresponding network FLOp and we extract some information about it:

data(flo)

FLO=graph_from_adjacency_matrix(flo,mode="undirected")

FLOp=delete_vertices(FLO,"Pucci")

VF=as_ids(V(FLOp)) #Vector of nodes

EF=as_ids(E(FLOp)) #Vector of edges

n=gorder(FLOp) #Order

m=ecount(FLOp) #Size

M=as.matrix(as_adjacency_matrix(FLOp)) # The adjacency matrix

plot(FLOp)

Names=attr(V(FLOp), "names")

Edges=attr(E(FLOp), "vnames")

Degree centralities

The (normalized) degree centrality of a node is simply (a normalized version of) its degree, as computed with degree in igraph :

round(igraph::degree(FLOp,normalized=TRUE),4)

## Acciaiuoli Albizzi Barbadori Bischeri Castellani

## 0.0714 0.2143 0.1429 0.2143 0.2143

## Ginori Guadagni Lamberteschi Medici Pazzi

## 0.0714 0.2857 0.0714 0.4286 0.0714

## Peruzzi Ridolfi Salviati Strozzi Tornabuoni

## 0.2143 0.2143 0.1429 0.2857 0.2143

Do not confuse it with degree in sna

sna::degree(M,gmode="graph") #sna works with adjacency matrices

## [1] 1 3 2 3 3 1 4 1 6 1 3 3 2 4 3

sna::degree(M,gmode="graph",rescale=TRUE)

## [1] 0.025 0.075 0.050 0.075 0.075 0.025 0.100 0.025 0.150 0.025 0.075

## [12] 0.075 0.050 0.100 0.075

round(sna::degree(M,gmode="graph")/(n-1),4)

## [1] 0.0714 0.2143 0.1429 0.2143 0.2143 0.0714 0.2857 0.0714 0.4286 0.0714

## [11] 0.2143 0.2143 0.1429 0.2857 0.2143

The lobby centrality (actually, a modification of it, because it includes the node itself in its neighborhood) can be computed with the function lobby in the centiserve package:

lobby(FLOp,v="Medici") #One node

## Medici

## 3

lobby(FLOp)

## Acciaiuoli Albizzi Barbadori Bischeri Castellani

## 1 3 2 3 3

## Ginori Guadagni Lamberteschi Medici Pazzi

## 1 3 1 3 1

## Peruzzi Ridolfi Salviati Strozzi Tornabuoni

## 3 3 2 3 3

The lobby centrality as defined in the lectures can be computed with the following function TLC:

TLC=function(G,v=as_ids(V(G))){

HH=function(x){

require(igraph)

D=as.numeric(igraph::degree(G, v=neighbors(G,v=x)))

z=sort(D,decreasing=TRUE)-(1:length(D))

max(which(z>=0))

}

unlist(sapply(v,FUN=HH))

}

TLC(FLOp,c("Medici","Albizzi"))

## Medici Albizzi

## 3 2

TLC(FLOp)

## Acciaiuoli Albizzi Barbadori Bischeri Castellani

## 1 2 2 3 2

## Ginori Guadagni Lamberteschi Medici Pazzi

## 1 3 1 3 1

## Peruzzi Ridolfi Salviati Strozzi Tornabuoni

## 3 3 1 3 3

Closeness centralities

The usual mean closeness centrality is closeness in igraph or in sna (with different syntax):

round(igraph::closeness(FLOp,normalized=TRUE,v="Medici"),4) #one node

## Medici

## 0.56

round(igraph::closeness(FLOp,normalized=TRUE),4)

## Acciaiuoli Albizzi Barbadori Bischeri Castellani

## 0.3684 0.4828 0.4375 0.4000 0.3889

## Ginori Guadagni Lamberteschi Medici Pazzi

## 0.3333 0.4667 0.3256 0.5600 0.2857

## Peruzzi Ridolfi Salviati Strozzi Tornabuoni

## 0.3684 0.5000 0.3889 0.4375 0.4828

round(sort(igraph::closeness(FLOp,normalized=TRUE),decreasing

...

Descargar como (para miembros actualizados)  txt (28.7 Kb)   pdf (69.6 Kb)   docx (567.4 Kb)  
Leer 27 páginas más »
Disponible sólo en Clubensayos.com