Analysis of the provided Networks.

Let’s read the structure

## Loading required package: plyr
## Loading required package: xtable
## Loading required package: igraph
## Loading required package: doMC
## Loading required package: foreach
## Loading required package: iterators
## Loading required package: parallel

Now we will build up the structural networks:

Types of networks.

For the particular type of size = 3 the meaning of each of the motifs can be found here: http://igraph.org/c/doc/igraph-Motifs.html

#
# for ( i in 1:length(graph.motifs(tnets,3))) {
#     cat(paste("<br>Isomorfism size: 3. Motif number:",(i),"<br>",sep=""))
#     plot(graph.isocreate(size=3,number=(i-1),directed=TRUE))
# }
# 
# for ( i in 1:length(graph.motifs(tnets,4))) {
#     cat(paste("<br>Isomorfism size: 4. Motif number:",(i),"<br>",sep=""))
#     plot(graph.isocreate(size=4,number=(i-1),directed=TRUE))
# }

Structural parameters of the networks

Let’s have a look into the network’s motifs.

#
cfgplt=function(net) {
  V(net)$size=degree(net)*1.2+3
#  layout = layout.reingold.tilford(net, circular=T)
  layout = layout.lgl
  plot.igraph(net,layout=layout,edge.arrow.size=0.25)
}
nm3s=unlist(lapply(nets,graph.motifs.no,size=3))
tnm3s=graph.motifs.no(tnets,size=3)
nm3f=unlist(lapply(nets,graph.motifs.no,size=3))
tnm3f=graph.motifs.no(tnetf,size=3)
print(xtable(as.data.frame(nm3s)),type="html")
nm3s
0 8
1 113
2 63
3 145
4 89
5 66
6 71
7 99
8 85
9 63
print(xtable(as.data.frame(tnm3s)),type="html")
tnm3s
1 922
print(xtable(as.data.frame(nm3f)),type="html")
nm3f
0 8
1 113
2 63
3 145
4 89
5 66
6 71
7 99
8 85
9 63
print(xtable(as.data.frame(tnm3f)),type="html")
tnm3f
1 3146
print(xtable(ldply(nets,graph.motifs,size=3)),type="html")
.id V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16
1 0 0.00 2.00 0.00 3.00 3.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
2 1 33.00 53.00 0.00 10.00 17.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
3 2 16.00 27.00 0.00 12.00 8.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
4 3 50.00 66.00 1.00 7.00 16.00 0.00 2.00 0.00 0.00 1.00 2.00 0.00 0.00
5 4 14.00 17.00 10.00 1.00 4.00 0.00 10.00 25.00 0.00 0.00 2.00 2.00 4.00
6 5 3.00 4.00 14.00 1.00 0.00 0.00 15.00 20.00 0.00 2.00 2.00 3.00 2.00
7 6 15.00 41.00 0.00 7.00 8.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
8 7 21.00 55.00 0.00 9.00 14.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
9 8 19.00 47.00 0.00 6.00 13.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
10 9 13.00 35.00 0.00 6.00 9.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
print(xtable(as.data.frame(graph.motifs(tnets,size=3))),type="html")
graph.motifs(tnets, size = 3)
1
2
3 269.00
4
5 382.00
6 25.00
7 51.00
8 103.00
9 0.00
10 27.00
11 45.00
12 0.00
13 3.00
14 6.00
15 5.00
16 6.00
print(xtable(ldply(netf,graph.motifs,size=3)),type="html")
.id V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16
1 0 15.00 0.00 0.00 56.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
2 1 0.00 2.00 13.00 1.00 0.00 0.00 19.00 120.00 0.00 0.00 0.00 13.00 35.00
3 2 17.00 46.00 44.00 22.00 15.00 6.00 38.00 21.00 2.00 13.00 10.00 8.00 2.00
4 3 135.00 242.00 139.00 138.00 77.00 39.00 169.00 25.00 11.00 35.00 28.00 31.00 6.00
5 4 69.00 84.00 90.00 47.00 53.00 23.00 85.00 13.00 11.00 46.00 16.00 41.00 5.00
6 5 25.00 33.00 45.00 16.00 21.00 14.00 35.00 21.00 10.00 21.00 17.00 20.00 8.00
7 6 4.00 16.00 25.00 6.00 4.00 3.00 22.00 9.00 0.00 0.00 1.00 12.00 6.00
8 7 9.00 40.00 25.00 14.00 4.00 7.00 27.00 13.00 1.00 4.00 5.00 12.00 7.00
9 8 4.00 17.00 17.00 6.00 4.00 0.00 21.00 5.00 0.00 3.00 3.00 7.00 4.00
10 9 0.00 2.00 11.00 2.00 4.00 3.00 25.00 20.00 0.00 2.00 3.00 6.00 4.00
print(xtable(as.data.frame(graph.motifs(tnetf,size=3))),type="html")
graph.motifs(tnetf, size = 3)
1
2
3 314.00
4
5 593.00
6 496.00
7 281.00
8 179.00
9 97.00
10 445.00
11 268.00
12 37.00
13 126.00
14 81.00
15 151.00
16 78.00
#
nm4s=unlist(lapply(nets,graph.motifs.no,size=4))
tnm4s=graph.motifs.no(tnets,size=4)
nm4f=unlist(lapply(nets,graph.motifs.no,size=4))
tnm4f=graph.motifs.no(tnetf,size=4)
print(xtable(as.data.frame(nm4s)),type="html")
nm4s
0 5
1 364
2 175
3 499
4 265
5 178
6 190
7 281
8 231
9 154
print(xtable(as.data.frame(tnm4s)),type="html")
tnm4s
1 3834
print(xtable(as.data.frame(nm4f)),type="html")
nm4f
0 5
1 364
2 175
3 499
4 265
5 178
6 190
7 281
8 231
9 154
print(xtable(as.data.frame(tnm4f)),type="html")
tnm4f
1 18220
print(xtable(t(ldply(nets,graph.motifs,size=4))),type="html")
1 2 3 4 5 6 7 8 9 10
.id 0 1 2 3 4 5 6 7 8 9
V1
V2
V3
V4 0 17 7 36 6 0 4 6 4 2
V5
V6
V7
V8 0 40 5 73 21 2 29 30 22 21
V9 0 0 0 0 6 5 0 0 0 0
V10
V11
V12
V13 0 70 33 173 19 0 36 46 62 27
V14 0 26 37 16 0 0 9 18 9 6
V15 0 25 12 39 7 0 11 17 12 10
V16
V17 0 0 0 0 0 6 0 0 0 0
V18 0 16 0 16 0 0 6 13 15 8
V19 0 0 0 0 0 0 0 0 0 0
V20 0 0 0 0 0 0 0 0 1 0
V21 0 2 0 0 0 0 0 1 0 1
V22 0 0 0 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0 0 0 0 0 0 0 0
V209 0 0 0 0 0 0 0 0 0 0
V210 0 0 0 0 0 0 0 0 0 0
V211 0 0 0 0 0 0 0 0 0 0
V212 0 0 0 0 0 0 0 0 0 0
V213 0 0 0 0 0 0 0 0 0 0
V214 0 0 0 0 0 0 0 0 0 0
V215 0 0 0 0 0 0 0 0 0 0
V216 0 0 0 0 0 0 0 0 0 0
V217 0 0 0 0 0 0 0 0 0 0
V218 0 0 0 0 0 0 0 0 0 0
print(xtable(as.data.frame(graph.motifs(tnets,size=4))),type="html")
graph.motifs(tnets, size = 4)
1
2
3
4 187.00
5
6
7
8 317.00
9 11.00
10
11
12
13 1199.00
14 234.00
15 211.00
16
17 6.00
18 128.00
19 0.00
20 2.00
21 17.00
22 0.00
23
24
25 110.00
26 12.00
27 9.00
28
29
30 402.00
31 0.00
32 8.00
33 1.00
34
35
36 155.00
37 0.00
38 4.00
39 0.00
40
41 5.00
42 101.00
43 172.00
44 0.00
45 4.00
46 88.00
47 53.00
48 23.00
49 0.00
50 2.00
51 0.00
52 1.00
53 7.00
54 0.00
55 0.00
56 0.00
57 6.00
58 10.00
59 40.00
60 0.00
61 1.00
62 0.00
63
64 0.00
65 6.00
66 2.00
67 12.00
68 11.00
69 0.00
70 0.00
71 0.00
72 0.00
73 0.00
74 0.00
75 0.00
76 0.00
77 10.00
78 15.00
79 3.00
80 0.00
81 8.00
82 0.00
83 2.00
84 3.00
85 0.00
86 0.00
87 0.00
88 0.00
89 0.00
90 0.00
91 0.00
92 0.00
93 0.00
94 26.00
95 20.00
96 0.00
97 1.00
98 1.00
99 34.00
100 0.00
101 16.00
102 4.00
103 0.00
104 1.00
105 4.00
106 8.00
107 0.00
108 4.00
109 13.00
110 0.00
111 1.00
112 0.00
113 1.00
114 0.00
115 0.00
116 0.00
117 0.00
118 1.00
119 0.00
120 5.00
121
122 7.00
123 4.00
124 1.00
125 3.00
126 40.00
127 1.00
128 2.00
129 0.00
130 0.00
131 0.00
132 0.00
133 0.00
134 0.00
135 0.00
136 0.00
137 1.00
138 0.00
139 0.00
140 7.00
141 0.00
142 5.00
143 17.00
144 0.00
145 0.00
146 0.00
147 0.00
148 0.00
149 0.00
150 0.00
151 0.00
152 0.00
153 0.00
154 1.00
155 1.00
156 0.00
157 0.00
158 0.00
159 0.00
160 0.00
161 0.00
162 0.00
163 0.00
164 0.00
165 0.00
166 0.00
167 1.00
168 0.00
169 0.00
170 0.00
171 0.00
172 0.00
173 0.00
174 1.00
175 0.00
176 0.00
177 0.00
178 0.00
179 0.00
180 0.00
181 0.00
182 0.00
183 0.00
184 0.00
185 0.00
186 0.00
187 0.00
188 0.00
189 0.00
190 0.00
191 0.00
192 0.00
193 0.00
194 0.00
195 0.00
196 0.00
197 0.00
198 0.00
199 0.00
200 0.00
201 0.00
202 0.00
203 1.00
204 0.00
205 0.00
206 3.00
207 0.00
208 0.00
209 0.00
210 0.00
211 0.00
212 0.00
213 0.00
214 0.00
215 0.00
216 0.00
217 0.00
218 0.00
print(xtable(t(ldply(netf,graph.motifs,size=4))),type="html")
1 2 3 4 5 6 7 8 9 10
.id 0 1 2 3 4 5 6 7 8 9
V1
V2
V3
V4 4 0 1 60 23 9 0 0 0 0
V5
V6
V7
V8 0 0 9 160 36 9 9 18 0 0
V9 0 0 16 95 50 6 2 8 3 0
V10
V11
V12
V13 0 0 21 416 43 5 2 18 13 0
V14 54 0 21 469 63 14 2 10 2 0
V15 0 0 5 107 45 14 2 2 0 0
V16
V17 0 0 33 75 25 11 4 2 1 0
V18 0 0 4 97 26 3 1 1 0 0
V19 0 0 5 93 49 9 2 6 0 0
V20 22 0 2 18 19 0 0 0 2 0
V21 0 0 1 11 10 4 0 0 1 0
V22 0 0 0 11 6 0 0 0 0 0
V23
V24
V25 0 0 14 138 24 2 12 36 8 1
V26 0 5 12 191 61 17 28 35 6 2
V27 0 7 13 28 13 10 9 0 0 0
V28
V29
V30 0 1 34 351 37 9 6 31 7 0
V31 0 0 7 54 26 18 0 3 0 0
V32 0 2 20 162 43 9 10 6 8 15
V33 0 0 10 50 40 17 0 2 0 0
V34
V35
V36 0 0 7 80 18 8 0 0 5 0
V37 0 0 24 33 21 8 0 5 4 0
V38 0 0 7 62 11 3 1 2 4 2
V39 0 0 7 46 30 7 5 6 4 0
V40
V41 0 4 31 227 45 17 11 35 15 0
V42 0 0 25 334 43 14 4 20 1 0
V43 0 0 25 112 15 12 6 3 3 0
V44 0 4 23 255 50 27 10 17 11 0
V45 0 0 9 38 17 7 8 3 1 4
V46 0 0 19 305 67 18 5 15 11 0
V47 0 31 33 65 10 19 13 10 9 14
V48 0 0 9 84 21 7 0 0 1 0
V49 0 0 6 120 29 11 5 7 0 2
V50 0 0 9 51 24 8 1 0 8 0
V51 0 0 5 29 11 16 6 3 0 4
V52 0 0 5 51 45 12 0 2 1 0
V53 0 0 8 50 21 0 0 2 0 0
V54 0 0 0 14 15 3 0 0 0 0
V55 0 0 2 36 30 2 0 0 0 0
V56 0 0 0 13 30 4 0 0 0 0
V57 0 0 2 37 25 15 1 5 1 0
V58 0 0 2 25 29 24 7 4 0 0
V59 0 0 3 24 19 0 0 0 1 0
V60 0 0 1 12 15 3 0 0 0 0
V61 0 0 3 25 12 8 0 0 0 0
V62 0 0 1 20 26 6 1 2 0 0
V63
V64 0 0 6 53 9 6 0 7 0 0
V65 0 2 5 27 31 9 1 0 2 0
V66 0 5 0 24 15 2 10 7 6 4
V67 0 0 10 28 7 4 0 0 0 0
V68 0 0 0 24 17 5 1 1 0 0
V69 0 0 7 24 22 6 1 0 0 0
V70 0 0 0 18 6 3 2 0 0 0
V71 0 0 0 17 4 4 0 1 0 0
V72 0 0 0 5 17 1 0 0 0 0
V73 0 0 2 20 12 4 0 4 0 0
V74 0 0 7 5 9 3 0 0 0 0
V75 0 0 5 8 13 6 0 1 0 2
V76 0 0 1 11 7 4 0 1 0 1
V77 75 0 5 81 7 3 1 7 0 0
V78 0 0 5 120 41 6 0 1 2 0
V79 0 0 0 14 8 2 0 1 0 0
V80 0 0 1 75 17 12 0 4 0 0
V81 0 0 0 27 12 1 1 0 0 0
V82 0 0 2 23 16 4 0 0 0 0
V83 0 0 4 10 2 1 0 0 0 0
V84 0 0 0 7 9 1 0 0 0 0
V85 0 0 0 9 3 1 0 0 0 0
V86 0 0 4 28 13 5 1 1 0 0
V87 0 0 0 5 1 2 0 0 0 0
V88 0 0 0 0 2 0 0 0 0 0
V89 0 0 0 7 4 3 0 0 0 1
V90 0 0 3 2 5 1 1 0 0 1
V91 0 0 0 5 7 3 1 1 0 0
V92 0 0 1 2 0 1 0 1 0 0
V93 0 3 19 160 16 1 9 14 4 8
V94 0 38 11 55 7 5 6 4 0 15
V95 0 101 5 6 0 4 2 0 0 0
V96 0 0 1 34 13 4 0 5 0 0
V97 0 1 14 122 18 3 1 1 4 0
V98 0 0 3 53 19 5 0 8 2 2
V99 0 1 36 241 64 15 13 32 7 0
V100 0 0 3 23 12 5 0 0 0 0
V101 0 18 26 72 15 17 16 10 6 18
V102 0 0 17 11 12 5 0 0 2 2
V103 0 0 2 65 18 2 0 8 2 0
V104 0 0 13 88 14 5 0 0 2 0
V105 0 0 12 62 27 5 0 6 4 10
V106 0 0 10 60 40 8 0 1 5 6
V107 0 0 7 12 9 9 0 0 2 0
V108 0 0 16 41 8 6 0 3 2 12
V109 0 14 10 6 4 3 3 1 1 10
V110 0 0 0 3 1 5 0 0 0 0
V111 0 0 3 47 33 1 0 0 0 0
V112 0 0 0 9 14 7 0 0 0 0
V113 0 0 2 10 6 0 0 0 0 0
V114 0 0 4 1 4 4 0 0 0 0
V115 0 0 2 2 11 0 0 0 0 0
V116 0 0 1 12 9 7 0 0 0 0
V117 0 0 0 6 12 4 0 0 0 0
V118 0 0 3 8 0 8 0 0 0 0
V119 0 0 0 4 5 5 0 0 0 0
V120 0 0 13 30 13 10 3 19 6 0
V121
V122 0 40 32 158 55 28 32 19 19 6
V123 0 0 6 17 14 14 2 3 2 2
V124 0 0 6 39 20 7 0 1 0 0
V125 0 0 2 45 21 7 10 11 7 2
V126 0 133 14 14 1 9 7 13 2 20
V127 0 0 9 30 30 7 0 2 4 0
V128 0 14 4 5 7 17 6 7 3 6
V129 0 0 2 7 3 0 0 0 0 0
V130 0 0 1 6 8 9 0 0 0 0
V131 0 0 1 26 9 0 0 0 0 0
V132 0 0 3 11 11 2 0 1 0 0
V133 0 0 0 1 2 2 0 2 0 0
V134 0 0 0 8 4 10 0 0 0 0
V135 0 0 5 3 8 4 0 0 0 0
V136 0 0 0 13 21 1 1 0 1 0
V137 0 0 2 8 12 4 0 4 0 0
V138 0 2 0 2 5 0 0 0 0 0
V139 0 8 4 43 33 5 5 0 3 0
V140 0 17 6 27 14 11 7 2 8 8
V141 0 0 0 41 14 5 1 5 0 3
V142 0 36 2 12 16 3 2 1 1 0
V143 0 156 3 3 1 2 3 8 1 13
V144 0 0 1 7 7 3 0 0 0 0
V145 0 0 0 11 5 4 0 1 0 0
V146 0 0 0 6 17 0 0 0 0 0
V147 0 2 7 8 8 1 1 1 2 0
V148 0 0 3 2 2 4 0 0 0 0
V149 0 0 1 12 8 3 0 0 0 0
V150 0 0 1 12 12 1 0 0 0 0
V151 0 0 1 3 11 0 0 0 0 0
V152 0 0 2 30 8 4 0 0 0 0
V153 0 0 3 10 1 2 1 2 0 0
V154 0 0 0 7 1 1 0 0 0 0
V155 0 2 0 5 3 1 0 0 0 0
V156 0 0 2 3 1 4 0 2 0 0
V157 0 0 0 5 6 4 0 0 0 0
V158 0 0 1 9 7 0 1 1 0 0
V159 0 0 2 4 13 3 0 0 0 0
V160 0 4 2 4 3 6 1 0 0 3
V161 0 0 0 6 5 8 0 0 0 0
V162 0 0 1 1 18 0 0 0 0 0
V163 0 0 0 7 11 7 1 1 0 0
V164 0 0 0 6 5 5 0 0 0 0
V165 0 0 0 22 7 4 1 0 0 0
V166 0 1 0 3 12 0 2 1 0 0
V167 0 0 4 3 2 8 0 2 0 0
V168 0 10 0 2 4 0 3 0 0 0
V169 0 0 0 1 5 4 0 0 0 0
V170 0 0 1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 0
V215 0 0 0 0 1 3 0 2 0 0
V216 0 0 0 1 2 0 0 1 0 0
V217 0 10 1 2 2 0 3 1 2 0
V218 0 14 0 0 0 2 0 1 0 0
print(xtable(as.data.frame(graph.motifs(tnetf,size=4))),type="html")
graph.motifs(tnetf, size = 4)
1
2
3
4 129.00
5
6
7
8 402.00
9 278.00
10
11
12
13 837.00
14 736.00
15 186.00
16
17 213.00
18 156.00
19 182.00
20 62.00
21 26.00
22 18.00
23
24
25 417.00
26 553.00
27 231.00
28
29
30 859.00
31 129.00
32 341.00
33 130.00
34
35
36 161.00
37 116.00
38 141.00
39 113.00
40
41 695.00
42 758.00
43 175.00
44 688.00
45 87.00
46 561.00
47 291.00
48 121.00
49 187.00
50 93.00
51 83.00
52 129.00
53 81.00
54 33.00
55 73.00
56 47.00
57 96.00
58 116.00
59 46.00
60 32.00
61 48.00
62 56.00
63
64 107.00
65 122.00
66 132.00
67 54.00
68 48.00
69 60.00
70 29.00
71 26.00
72 23.00
73 42.00
74 25.00
75 35.00
76 25.00
77 135.00
78 173.00
79 25.00
80 110.00
81 41.00
82 45.00
83 17.00
84 17.00
85 13.00
86 52.00
87 8.00
88 2.00
89 15.00
90 13.00
91 17.00
92 5.00
93 251.00
94 151.00
95 131.00
96 69.00
97 168.00
98 97.00
99 579.00
100 53.00
101 262.00
102 53.00
103 96.00
104 121.00
105 118.00
106 125.00
107 42.00
108 76.00
109 63.00
110 9.00
111 87.00
112 30.00
113 19.00
114 13.00
115 16.00
116 29.00
117 22.00
118 19.00
119 14.00
120 98.00
121
122 474.00
123 61.00
124 76.00
125 107.00
126 242.00
127 87.00
128 73.00
129 12.00
130 24.00
131 36.00
132 28.00
133 7.00
134 23.00
135 20.00
136 37.00
137 30.00
138 9.00
139 101.00
140 98.00
141 72.00
142 76.00
143 202.00
144 18.00
145 23.00
146 23.00
147 31.00
148 11.00
149 25.00
150 26.00
151 15.00
152 44.00
153 19.00
154 9.00
155 11.00
156 12.00
157 15.00
158 19.00
159 22.00
160 24.00
161 19.00
162 20.00
163 27.00
164 16.00
165 34.00
166 19.00
167 19.00
168 19.00
169 10.00
170 28.00
171 15.00
172 4.00
173 17.00
174 21.00
175 17.00
176 6.00
177 15.00
178 15.00
179 2.00
180 13.00
181 14.00
182 21.00
183 17.00
184 14.00
185 13.00
186 16.00
187 10.00
188 16.00
189 5.00
190 26.00
191 4.00
192 10.00
193 18.00
194 10.00
195 14.00
196 8.00
197 6.00
198 11.00
199 6.00
200 25.00
201 10.00
202 13.00
203 33.00
204 6.00
205 22.00
206 41.00
207 13.00
208 5.00
209 4.00
210 15.00
211 3.00
212 12.00
213 9.00
214 5.00
215 6.00
216 4.00
217 21.00
218 17.00
#
cat(paste("<br>Full Structural Network of hospitals:","<br>",sep=""))


Full Structural Network of hospitals:

cfgplt(tnets)

cat(paste("<br>Full Fucntional Network of hospitals:","<br>",sep=""))


Full Fucntional Network of hospitals:

cfgplt(tnetf)

cat("<hr>")

for (i in 1:numh){
  cat(paste("<br>Structural Network hospital:",(i-1),"<br>",sep=""))
  cfgplt(nets[[i]])
  cat(paste("<br>Functional Network hospital:",(i-1),"<br>",sep=""))
  cfgplt(netf[[i]])
}


Structural Network hospital:0

Functional Network hospital:0

Structural Network hospital:1

Functional Network hospital:1

Structural Network hospital:2

Functional Network hospital:2

Structural Network hospital:3

Functional Network hospital:3

Structural Network hospital:4

Functional Network hospital:4

Structural Network hospital:5

Functional Network hospital:5

Structural Network hospital:6

Functional Network hospital:6

Structural Network hospital:7

Functional Network hospital:7

Structural Network hospital:8

Functional Network hospital:8

Structural Network hospital:9

Functional Network hospital:9

#

Let us have a similat behaviour for a random network

#
rnet=function(net) {
  g=erdos.renyi.game(vcount(net),ecount(net),type="gnm",directed=TRUE)
  return(g)
}
rnets=lapply(nets,rnet)
trnets=rnet(tnets)
rnetf=lapply(netf,rnet)
trnetf=rnet(tnetf)
#
strt=data.frame(health_st=c(graph.motifs.no(tnets,size=3),
                            unlist(lapply(nets,graph.motifs.no,size=3))),
                random_st=c(graph.motifs.no(trnets,size=3),
                            unlist(lapply(rnets,graph.motifs.no,size=3))),
                health_fn=c(graph.motifs.no(tnetf,size=3),
                            unlist(lapply(netf,graph.motifs.no,size=3))),
                random_fn=c(graph.motifs.no(trnetf,size=3),
                            unlist(lapply(rnetf,graph.motifs.no,size=3)))
               )
rownames(strt)=c("Full Net",paste("Hosp. ",seq(1,length(rnets)),sep=""))
print(xtable(strt),type="html")
health_st random_st health_fn random_fn
Full Net 922 1376 3146 10099
Hosp. 1 8 7 71 51
Hosp. 2 113 129 203 631
Hosp. 3 63 72 244 403
Hosp. 4 145 162 1075 1758
Hosp. 5 89 184 583 722
Hosp. 6 66 100 286 356
Hosp. 7 71 64 108 252
Hosp. 8 99 105 168 435
Hosp. 9 85 88 91 295
Hosp. 10 63 69 82 186

Key Parameter Identification

#
radio=function(net){
  dg0=degree(net)
  hdg=which.max(dg0)[1]
  dg1=(1:length(dg0))[-hdg]
  return(mean(unlist(lapply(lapply(dg1,function(x,net){
        return(shortest.paths(net,hdg,x))},net=net), function(x) {
          if (is.infinite(x)) {
            return(NULL)
          } else {
            return(x)
          }
        })))
        )
}
diametro=function(net) {
  nv =length(V(net))
  sec=data.frame(o=1,d=2:nv)
  for (i in 2:nv) {
    if ( i < nv) {
      dd=data.frame(o=i,d=((i+1):nv))
      sec=rbind(sec,dd)
    }
  }
  sp=foreach(pos=1:nrow(sec)) %dopar%
      shortest.paths(net,sec[pos,1],sec[pos,2])
  
  return(mean(unlist(lapply(sp,function(x) {
          if (is.infinite(x)){
              return(NULL)}
          else{
              return(x)}
          }))))
}
#
nets_pl = ldply(nets,average.path.length)
netf_pl = ldply(netf,average.path.length)
tnets_pl= average.path.length(tnets)
tnetf_pl= average.path.length(tnetf)
nets_cc = ldply(nets,transitivity)
netf_cc = ldply(netf,transitivity)
tnets_cc= transitivity(tnets)
tnetf_cc= transitivity(tnetf)
nets_d  = ldply(nets,diametro)
netf_d  = ldply(netf,diametro)
tnets_d = diametro(tnets)
tnetf_d = diametro(tnetf)
nets_r  = ldply(nets,radio)
netf_r  = ldply(netf,radio)
tnets_r = radio(tnets)
tnetf_r = radio(tnetf)
nnds    = ldply(nets,function(x){return(length(V(x)))})
nndf    = ldply(netf,function(x){return(length(V(x)))})
tnnds   = length(V(tnets))
tnndf   = length(V(tnetf))
rnets_pl= ldply(rnets,average.path.length)
rnetf_pl= ldply(rnetf,average.path.length)
trnets_pl= average.path.length(trnets)
trnetf_pl= average.path.length(trnetf)
rnets_cc= ldply(rnets,transitivity)
rnetf_cc= ldply(rnetf,transitivity)
trnets_cc= transitivity(trnets)
trnetf_cc= transitivity(trnetf)
rnets_d = ldply(rnets,diametro)
rnetf_d = ldply(rnetf,diametro)
trnets_d= diametro(trnets)
trnetf_d= diametro(trnetf)
rnets_r = ldply(rnets,radio)
rnetf_r = ldply(rnetf,radio)
trnets_r= radio(trnets)
trnetf_r= radio(trnetf)
# 
ndt = data.frame(pls=c(tnets_pl,nets_pl[,2]),
                 plf=c(tnetf_pl,netf_pl[,2]),
                 ccs=c(tnets_cc,nets_cc[,2]),
                 ccf=c(tnetf_cc,netf_cc[,2]),
                 ds=c(tnets_d,nets_d[,2]),
                 df=c(tnetf_d,netf_d[,2]), 
                 rs=c(tnets_r,nets_r[,2]),
                 rf=c(tnetf_r,netf_r[,2]),                 
                 rpls=c(trnets_pl,rnets_pl[,2]), 
                 rplf=c(trnetf_pl,rnetf_pl[,2]),
                 rccs=c(trnets_cc,rnets_cc[,2]),
                 rccf=c(trnetf_cc,rnetf_cc[,2]),
                 rds=c(trnets_d,rnets_d[,2]),
                 rdf=c(trnetf_d,rnetf_d[,2]),
                 rrs=c(trnets_r,rnets_r[,2]),                 
                 rrf=c(trnetf_r,rnetf_r[,2]),                 
                 NS=c(tnnds,nnds[,2]),
                 NF=c(tnndf,nndf[,2]))
rownames(ndt) = c("Full Net",paste("Hosp.",(as.numeric(namh)+1),sep=" "))
print(xtable(ndt),type="html")
pls plf ccs ccf ds df rs rf rpls rplf rccs rccf rds rdf rrs rrf NS NF
Full Net 2.77 4.00 0.32 0.48 4.89 4.18 3.61 3.00 6.47 3.13 0.02 0.06 3.73 2.39 3.04 2.11 171 172
Hosp. 1 1.40 1.00 0.64 0.00 1.30 2.53 1.00 1.87 1.69 2.74 0.55 0.20 1.40 2.26 1.25 1.71 5 16
Hosp. 2 2.22 2.21 0.35 0.48 2.44 2.13 1.62 1.45 2.52 1.90 0.15 0.45 2.48 1.53 1.67 1.45 22 21
Hosp. 3 2.07 2.09 0.30 0.47 2.62 1.71 1.58 1.47 3.71 1.87 0.12 0.44 2.57 1.51 1.94 1.29 20 18
Hosp. 4 2.06 2.27 0.31 0.45 3.01 1.79 1.76 1.45 3.40 1.95 0.12 0.41 3.06 1.60 2.12 1.45 34 32
Hosp. 5 2.68 1.73 0.32 0.60 2.48 1.43 1.70 1.22 3.02 1.60 0.22 0.67 2.05 1.33 1.50 1.17 21 19
Hosp. 6 2.53 1.70 0.32 0.66 2.36 1.48 1.69 1.07 2.63 1.65 0.21 0.65 2.18 1.41 1.69 1.27 17 16
Hosp. 7 2.95 2.40 0.28 0.49 2.26 2.02 1.56 1.38 3.27 2.06 0.17 0.36 2.39 1.62 2.06 1.44 17 17
Hosp. 8 3.25 2.86 0.33 0.48 2.64 2.30 2.00 1.73 2.69 2.26 0.08 0.35 2.54 1.77 2.05 1.45 23 23
Hosp. 9 3.07 2.81 0.35 0.47 2.31 2.24 1.59 1.59 3.26 2.15 0.12 0.36 2.20 1.63 1.53 1.35 18 18
Hosp. 10 2.31 1.99 0.33 0.52 1.99 1.80 1.38 1.38 2.36 1.85 0.31 0.52 1.88 1.48 1.33 1.15 14 14

Checking some parameters

You can find here some checks as

#
mls = lm(ds~log(NS),data=ndt)
summary(mls)$adj.r.squared

[1] 0.9769848

print(xtable(summary(mls)),type="html")
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.6333 0.1606 -3.94 0.0034
log(NS) 1.0454 0.0507 20.63 0.0000
plot(mls)

mlf = lm(df~log(NF),data=ndt)
summary(mlf)$adj.r.squared

[1] 0.6893916

print(xtable(summary(mlf)),type="html")
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.7264 0.6103 -1.19 0.2644
log(NF) 0.9156 0.1901 4.82 0.0010
plot(mlf)

Communities per network

Let’s define communities in a network by just looking for dense subgraphs. The selected criterion will be to maximize the modularity.

#
complt=function(net,plt=FALSE) {
  layout = layout.lgl
  wc=optimal.community(net)
  if ( plt) {
    g=net
    V(g)$color=membership(wc)
    plot.igraph(g,layout=layout)
  }
  return(list(md=modularity(wc),nc=max(membership(wc))))
}
submotifs=function(net,plt=TRUE){
  wc=optimal.community(net)
  res=matrix(NA,nrow=max(membership(wc)),ncol=5)
  for ( i in 1:max(membership(wc))) {
    net3=induced.subgraph(net,(1:length(V(net)))[membership(wc)==i])
    if (plt) {
      plot(net3)
    }
    n4 = graph.motifs.no(net3,size=4)
    res[i,1]=length(V(net3))
    res[i,2]=length(E(net3))
    res[i,3]=graph.motifs.no(net3,size=3)
    res[i,4]=graph.motifs.no(net3,size=4)
  }
  res[,5]=modularity(wc)
  dres=as.data.frame(res)
  colnames(dres)=c("Nodes","Edges","3-Motif","4-Motif","Modularity")
  return(dres)
}
#
#
cat("NET-S communities")

NET-S communities

lnts=lapply(nets,complt,plt=FALSE)
#
cat("NET-F communities")

NET-F communities

lntf=lapply(netf,complt,plt=FALSE)
#
cat("NET-S communities")

NET-S communities

for ( i in 1:length(nets)){
  cat(paste(" -> NET-S  Hosp:",i,sep=""))
  print(xtable(submotifs(nets[[i]],plt=FALSE)),type="html")
}
-> NET-S Hosp:1
Nodes Edges 3-Motif 4-Motif Modularity
1 3.00 3.00 1.00 0.00 0.12
2 2.00 1.00 0.00 0.00 0.12
-> NET-S Hosp:2
Nodes Edges 3-Motif 4-Motif Modularity
1 7.00 10.00 18.00 22.00 0.51
2 4.00 5.00 4.00 1.00 0.51
3 6.00 9.00 14.00 13.00 0.51
4 5.00 6.00 7.00 4.00 0.51
-> NET-S Hosp:3
Nodes Edges 3-Motif 4-Motif Modularity
1 7.00 8.00 13.00 15.00 0.54
2 4.00 4.00 3.00 1.00 0.54
3 3.00 3.00 1.00 0.00 0.54
4 6.00 9.00 13.00 12.00 0.54
-> NET-S Hosp:4
Nodes Edges 3-Motif 4-Motif Modularity
1 11.00 17.00 33.00 65.00 0.64
2 8.00 10.00 15.00 20.00 0.64
3 4.00 5.00 3.00 1.00 0.64
4 6.00 9.00 13.00 12.00 0.64
5 5.00 9.00 9.00 5.00 0.64
-> NET-S Hosp:5
Nodes Edges 3-Motif 4-Motif Modularity
1 7.00 9.00 17.00 21.00 0.51
2 5.00 9.00 8.00 5.00 0.51
3 5.00 14.00 8.00 5.00 0.51
4 4.00 8.00 3.00 1.00 0.51
-> NET-S Hosp:6
Nodes Edges 3-Motif 4-Motif Modularity
1 7.00 13.00 15.00 20.00 0.42
2 4.00 5.00 3.00 1.00 0.42
3 6.00 12.00 11.00 10.00 0.42
-> NET-S Hosp:7
Nodes Edges 3-Motif 4-Motif Modularity
1 5.00 7.00 8.00 5.00 0.45
2 5.00 6.00 7.00 5.00 0.45
3 7.00 8.00 16.00 20.00 0.45
-> NET-S Hosp:8
Nodes Edges 3-Motif 4-Motif Modularity
1 6.00 7.00 8.00 7.00 0.49
2 6.00 8.00 10.00 9.00 0.49
3 5.00 6.00 7.00 4.00 0.49
4 6.00 7.00 11.00 10.00 0.49
-> NET-S Hosp:9
Nodes Edges 3-Motif 4-Motif Modularity
1 4.00 5.00 4.00 1.00 0.43
2 4.00 5.00 4.00 1.00 0.43
3 4.00 5.00 4.00 1.00 0.43
4 6.00 7.00 11.00 10.00 0.43
-> NET-S Hosp:10
Nodes Edges 3-Motif 4-Motif Modularity
1 5.00 7.00 8.00 5.00 0.37
2 3.00 3.00 1.00 0.00 0.37
3 6.00 7.00 11.00 10.00 0.37
# cat(paste(" -> NET-S  Full Size:",sep=""))
# print(xtable(submotifs(tnets,plt=FALSE)),type="html")
cat("NET-F communities")

NET-F communities

for ( i in 1:length(nets)){
  cat(paste(" -> NET-F  Hosp:",i,sep=""))
  print(xtable(submotifs(nets[[i]],plt=FALSE)),type="html")
}
-> NET-F Hosp:1
Nodes Edges 3-Motif 4-Motif Modularity
1 3.00 3.00 1.00 0.00 0.12
2 2.00 1.00 0.00 0.00 0.12
-> NET-F Hosp:2
Nodes Edges 3-Motif 4-Motif Modularity
1 7.00 10.00 18.00 22.00 0.51
2 4.00 5.00 4.00 1.00 0.51
3 6.00 9.00 14.00 13.00 0.51
4 5.00 6.00 7.00 4.00 0.51
-> NET-F Hosp:3
Nodes Edges 3-Motif 4-Motif Modularity
1 7.00 8.00 13.00 15.00 0.54
2 4.00 4.00 3.00 1.00 0.54
3 3.00 3.00 1.00 0.00 0.54
4 6.00 9.00 13.00 12.00 0.54
-> NET-F Hosp:4
Nodes Edges 3-Motif 4-Motif Modularity
1 11.00 17.00 33.00 65.00 0.64
2 8.00 10.00 15.00 20.00 0.64
3 4.00 5.00 3.00 1.00 0.64
4 6.00 9.00 13.00 12.00 0.64
5 5.00 9.00 9.00 5.00 0.64
-> NET-F Hosp:5
Nodes Edges 3-Motif 4-Motif Modularity
1 7.00 9.00 17.00 21.00 0.51
2 5.00 9.00 8.00 5.00 0.51
3 5.00 14.00 8.00 5.00 0.51
4 4.00 8.00 3.00 1.00 0.51
-> NET-F Hosp:6
Nodes Edges 3-Motif 4-Motif Modularity
1 7.00 13.00 15.00 20.00 0.42
2 4.00 5.00 3.00 1.00 0.42
3 6.00 12.00 11.00 10.00 0.42
-> NET-F Hosp:7
Nodes Edges 3-Motif 4-Motif Modularity
1 5.00 7.00 8.00 5.00 0.45
2 5.00 6.00 7.00 5.00 0.45
3 7.00 8.00 16.00 20.00 0.45
-> NET-F Hosp:8
Nodes Edges 3-Motif 4-Motif Modularity
1 6.00 7.00 8.00 7.00 0.49
2 6.00 8.00 10.00 9.00 0.49
3 5.00 6.00 7.00 4.00 0.49
4 6.00 7.00 11.00 10.00 0.49
-> NET-F Hosp:9
Nodes Edges 3-Motif 4-Motif Modularity
1 4.00 5.00 4.00 1.00 0.43
2 4.00 5.00 4.00 1.00 0.43
3 4.00 5.00 4.00 1.00 0.43
4 6.00 7.00 11.00 10.00 0.43
-> NET-F Hosp:10
Nodes Edges 3-Motif 4-Motif Modularity
1 5.00 7.00 8.00 5.00 0.37
2 3.00 3.00 1.00 0.00 0.37
3 6.00 7.00 11.00 10.00 0.37
# cat(paste(" -> NET-F  Full Size:",sep=""))
# print(xtable(submotifs(tnetf,plt=FALSE)),type="html")
#

Equivalent hierarchical networks

Let’s determine the size of a ‘tree type’ network

#
creatree=function(x){
  return(graph.tree(x[2],x[1],mode="in"))
}
sacamotifs=function(net){
    res=rep(0,4)
    res[1]=length(V(net))
    res[2]=length(E(net))
    res[3]=graph.motifs.no(net,size=3)
    res[4]=graph.motifs.no(net,size=4)
    return(res)
}
# To calculate the averaged number of connections entering into a node
vecinos=function(net) {
  return( round( 0.5 + mean(degree(net,mode="in"))))
}
tns=merge(ldply(nets,vecinos),ldply(nets,function(x){return(length(V(x)))}),by=".id")
colnames(tns)=c("ID","NH","NN")
tns=rbind(c(vecinos(tnets),length(V(tnets))),tns[,-1])
rownames(tns)=c("Full Size",paste("Hosp. ",seq(1:length(nets)),sep=""))
tnf=merge(ldply(netf,vecinos),ldply(netf,function(x){return(length(V(x)))}),by=".id")
colnames(tnf)=c("ID","NH","NN")
tnf=rbind(c(vecinos(tnetf),length(V(tnetf))),tnf[,-1])
rownames(tnf)=c("Full Size",paste("Hosp. ",seq(1:length(netf)),sep=""))
cat("NET-S communities")

NET-S communities

print(xtable(tns),type="html")
NH NN
Full Size 3.00 171.00
Hosp. 1 2.00 5.00
Hosp. 2 2.00 22.00
Hosp. 3 2.00 20.00
Hosp. 4 2.00 34.00
Hosp. 5 3.00 21.00
Hosp. 6 3.00 17.00
Hosp. 7 2.00 17.00
Hosp. 8 2.00 23.00
Hosp. 9 2.00 18.00
Hosp. 10 2.00 14.00
cat("NET-F communities")

NET-F communities

print(xtable(tnf),type="html")
NH NN
Full Size 6.00 172.00
Hosp. 1 2.00 16.00
Hosp. 2 6.00 21.00
Hosp. 3 6.00 18.00
Hosp. 4 8.00 32.00
Hosp. 5 8.00 19.00
Hosp. 6 7.00 16.00
Hosp. 7 4.00 17.00
Hosp. 8 4.00 23.00
Hosp. 9 4.00 18.00
Hosp. 10 5.00 14.00
#
netts=apply(tns,1,creatree)
nettf=apply(tnf,1,creatree)
#
netts_pl = ldply(netts,average.path.length)
nettf_pl = ldply(nettf,average.path.length)
netts_cc = ldply(netts,transitivity)
nettf_cc = ldply(nettf,transitivity)
netts_d  = ldply(netts,diametro)
nettf_d  = ldply(nettf,diametro)
netts_r  = ldply(netts,radio)
nettf_r  = ldply(nettf,radio)
nndts    = tns[,2]
nndtf    = tnf[,2]
# 
ndtt = data.frame(pls=netts_pl[,2],
                 plf=nettf_pl[,2],
                 ccs=netts_cc[,2],
                 ccf=nettf_cc[,2],
                 ds=netts_d[,2],
                 df=nettf_d[,2], 
                 rs=netts_r[,2],
                 rf=nettf_r[,2],                               
                 NS=nndts,
                 NF=nndtf)
rownames(ndtt) = c("Full Net",paste("Hosp.",(as.numeric(namh)+1),sep=" "))
print(xtable(ndtt),type="html")
pls plf ccs ccf ds df rs rf NS NF
Full Net 2.59 1.91 0.00 0.00 6.78 4.92 3.92 3.22 171.00 172.00
Hosp. 1 1.33 1.89 0.00 0.00 1.80 3.67 1.25 2.53 5.00 16.00
Hosp. 2 2.13 1.41 0.00 0.00 4.22 2.81 2.67 2.05 22.00 21.00
Hosp. 3 2.07 1.39 0.00 0.00 4.06 2.64 2.63 1.88 20.00 18.00
Hosp. 4 2.36 1.43 0.00 0.00 5.20 2.97 3.36 2.19 34.00 32.00
Hosp. 5 1.73 1.36 0.00 0.00 3.40 2.49 2.10 1.61 21.00 19.00
Hosp. 6 1.64 1.35 0.00 0.00 3.19 2.39 2.12 1.53 17.00 16.00
Hosp. 7 1.95 1.43 0.00 0.00 3.78 2.85 2.56 2.19 17.00 17.00
Hosp. 8 2.15 1.52 0.00 0.00 4.27 3.23 2.68 2.32 23.00 23.00
Hosp. 9 2.00 1.43 0.00 0.00 3.88 2.93 2.59 2.24 18.00 18.00
Hosp. 10 1.81 1.38 0.00 0.00 3.42 2.54 2.38 1.77 14.00 14.00
pnetts = ldply(netts,sacamotifs)
pnettf = ldply(netts,sacamotifs)
pnets  =rbind(c(1,sacamotifs(tnets)),ldply(nets,sacamotifs))[,-1]
rownames(pnets) = c("Full Net",paste("Hosp.",(as.numeric(namh)+1),sep=" "))
colnames(pnets)=c("Nodes","Edges","3-Motif","4-Motif")
pnetf  =rbind(c(1,sacamotifs(tnetf)),ldply(netf,sacamotifs))[,-1]
rownames(pnetf) = c("Full Net",paste("Hosp.",(as.numeric(namh)+1),sep=" "))
colnames(pnetf)=c("Nodes","Edges","3-Motif","4-Motif")
cat("NET-S communities. SW network + Tree network")

NET-S communities. SW network + Tree network

print(xtable(pnets),type="html")
Nodes Edges 3-Motif 4-Motif
Full Net 171.00 346.00 922.00 3834.00
Hosp. 1 5.00 7.00 8.00 5.00
Hosp. 2 22.00 39.00 113.00 364.00
Hosp. 3 20.00 29.00 63.00 175.00
Hosp. 4 34.00 58.00 145.00 499.00
Hosp. 5 21.00 52.00 89.00 265.00
Hosp. 6 17.00 39.00 66.00 178.00
Hosp. 7 17.00 27.00 71.00 190.00
Hosp. 8 23.00 38.00 99.00 281.00
Hosp. 9 18.00 33.00 85.00 231.00
Hosp. 10 14.00 24.00 63.00 154.00
print(xtable(pnetts),type="html")
.id V1 V2 V3 V4
1 Full Size 171.00 170.00 336.00 714.00
2 Hosp. 1 5.00 4.00 4.00 3.00
3 Hosp. 2 22.00 21.00 29.00 43.00
4 Hosp. 3 20.00 19.00 26.00 38.00
5 Hosp. 4 34.00 33.00 47.00 73.00
6 Hosp. 5 21.00 20.00 36.00 64.00
7 Hosp. 6 17.00 16.00 28.00 47.00
8 Hosp. 7 17.00 16.00 22.00 31.00
9 Hosp. 8 23.00 22.00 31.00 46.00
10 Hosp. 9 18.00 17.00 23.00 33.00
11 Hosp. 10 14.00 13.00 17.00 23.00
cat("NET-F communities. SW network + Tree network")

NET-F communities. SW network + Tree network

print(xtable(pnetf),type="html")
Nodes Edges 3-Motif 4-Motif
Full Net 172.00 975.00 3146.00 18220.00
Hosp. 1 16.00 23.00 71.00 155.00
Hosp. 2 21.00 114.00 203.00 750.00
Hosp. 3 18.00 90.00 244.00 961.00
Hosp. 4 32.00 226.00 1075.00 7523.00
Hosp. 5 19.00 144.00 583.00 2739.00
Hosp. 6 16.00 98.00 286.00 1021.00
Hosp. 7 17.00 64.00 108.00 345.00
Hosp. 8 23.00 89.00 168.00 581.00
Hosp. 9 18.00 68.00 91.00 248.00
Hosp. 10 14.00 59.00 82.00 210.00
print(xtable(pnettf),type="html")
.id V1 V2 V3 V4
1 Full Size 171.00 170.00 336.00 714.00
2 Hosp. 1 5.00 4.00 4.00 3.00
3 Hosp. 2 22.00 21.00 29.00 43.00
4 Hosp. 3 20.00 19.00 26.00 38.00
5 Hosp. 4 34.00 33.00 47.00 73.00
6 Hosp. 5 21.00 20.00 36.00 64.00
7 Hosp. 6 17.00 16.00 28.00 47.00
8 Hosp. 7 17.00 16.00 22.00 31.00
9 Hosp. 8 23.00 22.00 31.00 46.00
10 Hosp. 9 18.00 17.00 23.00 33.00
11 Hosp. 10 14.00 13.00 17.00 23.00
#

We plot now in a visible way the nets:

#
#
par(mai=c(0,0,1,0)) 
net=tnets
V(net)$size<-degree(net)/100
plot(net,           #the graph to be plotted
layout=layout.fruchterman.reingold, 
vertex.label.dist=0.1,          #puts the name labels slightly off the dots
vertex.frame.color='blue',      #the color of the border of the dots 
vertex.label.color='black',     #the color of the name labels
vertex.label.font=2,            #the font of the name labels
vertex.label=V(net)$name,       
vertex.label.cex=0.6, #specifies the size of the font of the labels. can also be made to vary
edge.arrow.size=0.3, layout=layout.lgl
)

#
par(mai=c(0,0,1,0)) 
net=tnetf
V(net)$size<-degree(net)/100
plot(net,       #the graph to be plotted
layout=layout.fruchterman.reingold, 
vertex.label.dist=0.1,          #puts the name labels slightly off the dots
vertex.frame.color='blue',      #the color of the border of the dots 
vertex.label.color='black',     #the color of the name labels
vertex.label.font=2,            #the font of the name labels
vertex.label=V(net)$name,       
vertex.label.cex=0.6, #specifies the size of the font of the labels. can also be made to vary
edge.arrow.size=0.3, layout=layout.graphopt
)

#
#

Z-Score values

Now it is time for calculating the z-score of the netwoeks

#
rewiringnet=function(net,iter=1000){
  nts = net
  zval=graph.motifs(net,size=3)
  tmp =matrix(NA,nrow=iter,ncol=length(zval))
  for ( i in 1:iter) {
    tmp[i,] = graph.motifs(rewire(net,mode="simple"),size=3)
  }
  mu  =apply(tmp,2,mean)
  std =apply(tmp,2,sd)
  return((zval-mu)/std)
}
#
znets=rbind(c(1,rewiringnet(tnets)),ldply(nets,rewiringnet))[,-1]
rownames(znets) = c("Full Net",paste("Hosp.",(as.numeric(namh)+1),sep=" "))
znetf=rbind(c(1,rewiringnet(tnetf)),ldply(netf,rewiringnet))[,-1]
rownames(znetf) = c("Full Net",paste("Hosp.",(as.numeric(namh)+1),sep=" "))
print(xtable(znets),type="html")
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16
Full Net -10.21 -7.84 -1.92 -11.33 14.65 -0.89 -2.04 10.01 -1.47 0.59 3.72 3.07 11.79
Hosp. 1 0.72 -0.72 0.72 -0.72
Hosp. 2 -0.79 1.05 -1.58 -2.13 5.74 -0.59 -1.61 -0.53 -1.05 -0.69 -0.49 -0.22
Hosp. 3 -3.08 0.30 -0.99 -0.87 4.31 -1.03 -0.29 -0.70 -0.16 -0.38
Hosp. 4 -1.46 -1.19 -1.01 -6.50 6.50 -0.40 -0.16 -0.28 -1.16 1.76 8.76 -0.08
Hosp. 5 -3.10 -4.46 -1.61 -4.51 -1.25 -1.24 -1.22 10.10 -2.03 -1.99 0.77 1.04 17.53
Hosp. 6 -2.68 -3.53 -0.61 -2.96 -1.63 -1.35 -0.78 4.91 -1.66 -1.25 0.71 0.48 3.25
Hosp. 7 0.30 1.90 -1.74 -0.59 4.07 -0.48 -1.71 -0.54 -1.14 -0.76 -0.35 -0.23
Hosp. 8 -0.92 1.01 -1.39 -2.35 6.54 -0.47 -1.36 -0.41 -1.30 -0.65 -0.34 -0.21
Hosp. 9 -0.90 1.26 -1.56 -2.19 5.34 -0.46 -1.54 -0.44 -1.20 -0.64 -0.42 -0.20
Hosp. 10 0.18 2.08 -1.84 -0.62 4.20 -0.59 -1.77 -0.61 -1.03 -0.79 -0.48 -0.29 -0.03
print(xtable(znetf),type="html")
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16
Full Net -9.74 -9.89 -6.21 -9.80 0.15 4.30 -6.04 6.44 -0.64 2.90 3.22 5.63 8.42
Hosp. 1
Hosp. 2 -4.01 -5.06 -7.56 -3.82 -2.22 -2.74 -7.64 7.89 -2.39 -4.08 -3.02 -3.22 7.83
Hosp. 3 -3.28 -2.88 1.16 -2.92 -1.57 -0.07 0.19 3.27 -2.13 0.16 1.59 1.16 2.90
Hosp. 4 -3.61 -3.54 0.39 -4.68 -2.06 3.30 1.64 0.47 -2.33 0.22 1.20 3.62 4.71
Hosp. 5 -0.25 -1.64 0.54 -1.45 -1.38 -1.29 2.09 -1.21 -1.22 0.27 -1.06 1.88 0.94
Hosp. 6 -1.22 -2.57 -0.30 -2.32 -1.59 -0.67 -0.63 1.19 -0.31 -1.42 1.15 -0.27 3.55
Hosp. 7 -3.58 -3.75 0.18 -3.77 -1.83 -0.62 0.15 1.21 -2.22 -3.10 -1.13 4.55 11.67
Hosp. 8 -4.29 -4.15 -0.95 -4.21 -2.31 2.17 -0.77 2.46 -2.36 -1.56 1.20 5.82 17.24
Hosp. 9 -4.28 -4.48 0.37 -4.10 -1.63 -1.12 0.44 1.51 -2.31 -0.16 1.43 7.67 20.95
Hosp. 10 -3.76 -4.12 -1.12 -4.06 -1.38 0.10 0.52 4.47 -1.76 -2.20 -0.27 0.78 5.37
#