Objective

This file was created to calculate modularity and E-I index based on igrpah package for the entire dataset of SMRs in Canada. We use two files to rebuild the dataset and being able to calculate the indexes:

First we load all the files from the adjacency matrix exported from visone

##Building graphs

After getting the matrices, we build the graphs based on igrpah

At this point we had all the graphs, but we need to add some attributes before making the calculations. The following section do that after opening the files with those attributes

Then we create the functions to merge the data in the graph file

Finally, we complete the merging and verify the results.

##Plotting graphs At this point we have finished the procedure of transforming adjacency matrices in graphs and we have added the attributes. We are ready to plot the graphs.

## IGRAPH 905b6d7 UNW- 4 2 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 905b6d7 (vertex names):
## [1] 476--965 570--965

## IGRAPH cf8098b UNW- 7 4 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from cf8098b (vertex names):
## [1] 1178--1180 141 --144  141 --860  144 --860

## IGRAPH d8183af UNW- 5 5 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from d8183af (vertex names):
## [1] 1192--1211 1192--694  1211--264  1211--694  264 --694

## IGRAPH 1e2124e UNW- 23 95 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 1e2124e (vertex names):
##  [1] 1005--1176 1005--1192 1005--1211 1005--1220 1005--141  1005--144 
##  [7] 1005--146  1005--338  1005--347  1005--358  1005--381  1005--387 
## [13] 1005--408  1005--411  1005--522  1005--65   1005--696  1005--824 
## [19] 1005--860  1176--1192 1176--141  1176--338  1176--358  1176--381 
## [25] 1176--411  1176--65   1176--696  1176--860  1192--141  1192--338 
## [31] 1192--358  1192--381  1192--411  1192--65   1192--696  1192--860 
## [37] 1211--144  1211--146  1211--347  1211--358  1211--381  1211--387 
## + ... omitted several edges

## IGRAPH 204fd0b UNW- 53 466 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 204fd0b (vertex names):
##  [1] 1005--1040 1005--1101 1005--1192 1005--141  1005--144  1005--146 
##  [7] 1005--237  1005--311  1005--312  1005--316  1005--347  1005--358 
## [13] 1005--381  1005--411  1005--413  1005--476  1005--522  1005--523 
## [19] 1005--527  1005--532  1005--536  1005--543  1005--544  1005--545 
## [25] 1005--562  1005--578  1005--988  1036--190  1036--391  1036--525 
## [31] 1036--535  1036--546  1036--553  1036--557  1036--563  1036--914 
## [37] 1040--141  1040--316  1040--347  1040--358  1040--413  1040--476 
## + ... omitted several edges

## IGRAPH 90e3c9c UNW- 73 813 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 90e3c9c (vertex names):
##  [1] 1005--1045 1005--1176 1005--141  1005--144  1005--151  1005--290 
##  [7] 1005--316  1005--347  1005--358  1005--381  1005--476  1005--522 
## [13] 1005--543  1005--565  1005--574  1005--575  1005--580  1005--586 
## [19] 1005--587  1005--588  1005--589  1005--590  1005--591  1005--595 
## [25] 1005--600  1005--624  1005--694  1005--700  1005--723  1005--758 
## [31] 1005--965  1045--1176 1045--141  1045--144  1045--151  1045--316 
## [37] 1045--347  1045--354  1045--358  1045--381  1045--470  1045--476 
## + ... omitted several edges

## IGRAPH c839648 UNW- 44 386 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from c839648 (vertex names):
##  [1] 1005--151  1005--234  1005--381  1005--391  1005--408  1005--411 
##  [7] 1005--413  1005--476  1005--508  1005--543  1005--545  1005--570 
## [13] 1005--681  1005--76   1005--818  1005--829  1101--1253 1101--141 
## [19] 1101--144  1101--151  1101--234  1101--237  1101--316  1101--358 
## [25] 1101--381  1101--408  1101--411  1101--476  1101--500  1101--508 
## [31] 1101--527  1101--532  1101--570  1101--581  1101--607  1101--65  
## [37] 1101--694  1101--76   1101--764  1101--792  1101--848  1101--860 
## + ... omitted several edges

## IGRAPH 28078f5 UNW- 260 15003 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 28078f5 (vertex names):
##  [1] 1000--1002 1000--1005 1000--1017 1000--104  1000--1040 1000--108 
##  [7] 1000--1101 1000--1104 1000--1132 1000--1139 1000--1153 1000--1179
## [13] 1000--1197 1000--121  1000--1225 1000--1251 1000--139  1000--141 
## [19] 1000--143  1000--144  1000--146  1000--147  1000--151  1000--152 
## [25] 1000--167  1000--174  1000--185  1000--195  1000--205  1000--215 
## [31] 1000--219  1000--223  1000--232  1000--233  1000--234  1000--247 
## [37] 1000--250  1000--262  1000--264  1000--270  1000--285  1000--286 
## + ... omitted several edges

## IGRAPH 9939cb2 UNW- 246 13222 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 9939cb2 (vertex names):
##  [1] 1005--102  1005--1031 1005--1036 1005--104  1005--1040 1005--1047
##  [7] 1005--1053 1005--1070 1005--1076 1005--1099 1005--1130 1005--1137
## [13] 1005--1148 1005--117  1005--1176 1005--119  1005--121  1005--1211
## [19] 1005--129  1005--135  1005--140  1005--143  1005--144  1005--146 
## [25] 1005--147  1005--148  1005--149  1005--151  1005--156  1005--157 
## [31] 1005--163  1005--164  1005--167  1005--169  1005--170  1005--175 
## [37] 1005--177  1005--179  1005--181  1005--183  1005--191  1005--195 
## + ... omitted several edges

## IGRAPH 2e4bd93 UNW- 22 94 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 2e4bd93 (vertex names):
##  [1] 1005--1176 1005--1192 1005--1211 1005--1220 1005--141  1005--144 
##  [7] 1005--215  1005--264  1005--338  1005--347  1005--358  1005--408 
## [13] 1005--476  1005--522  1005--65   1005--694  1005--860  1005--965 
## [19] 1176--1192 1176--141  1176--338  1176--65   1176--965  1178--1180
## [25] 1178--570  1180--570  1180--965  1192--1211 1192--141  1192--144 
## [31] 1192--215  1192--338  1192--347  1192--476  1192--522  1192--65  
## [37] 1192--694  1192--860  1192--965  1211--141  1211--144  1211--215 
## + ... omitted several edges

## IGRAPH 849caaf UNW- 111 2113 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 849caaf (vertex names):
##  [1] 1005--1040 1005--1045 1005--1101 1005--1176 1005--1192 1005--1236
##  [7] 1005--141  1005--144  1005--146  1005--151  1005--237  1005--290 
## [13] 1005--311  1005--312  1005--316  1005--338  1005--347  1005--358 
## [19] 1005--381  1005--411  1005--413  1005--476  1005--508  1005--522 
## [25] 1005--523  1005--527  1005--532  1005--536  1005--543  1005--544 
## [31] 1005--545  1005--562  1005--565  1005--571  1005--573  1005--574 
## [37] 1005--575  1005--578  1005--580  1005--581  1005--582  1005--586 
## + ... omitted several edges

## IGRAPH 86d82c6 UNW- 374 32701 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 86d82c6 (vertex names):
##  [1] 1000--1002 1000--1005 1000--1017 1000--1036 1000--104  1000--1040
##  [7] 1000--1076 1000--108  1000--1101 1000--1104 1000--1132 1000--1137
## [13] 1000--1139 1000--1153 1000--1179 1000--1197 1000--121  1000--1225
## [19] 1000--1251 1000--1253 1000--139  1000--141  1000--143  1000--144 
## [25] 1000--146  1000--147  1000--148  1000--151  1000--152  1000--167 
## [31] 1000--170  1000--174  1000--177  1000--183  1000--185  1000--195 
## [37] 1000--201  1000--205  1000--215  1000--219  1000--222  1000--223 
## + ... omitted several edges

## IGRAPH 7c58113 UNW- 71 901 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 7c58113 (vertex names):
##  [1] 1000--1002 1000--1005 1000--1017 1000--104  1000--1040 1000--121 
##  [7] 1000--141  1000--146  1000--174  1000--205  1000--222  1000--223 
## [13] 1000--234  1000--342  1000--354  1000--366  1000--381  1000--408 
## [19] 1000--411  1000--413  1000--532  1000--581  1000--694  1000--860 
## [25] 1000--966  1000--992  1002--1005 1002--141  1002--174  1002--205 
## [31] 1002--223  1002--285  1002--354  1002--366  1002--381  1002--411 
## [37] 1002--413  1002--532  1002--581  1002--694  1002--860  1005--1007
## + ... omitted several edges

## IGRAPH 90608ea UNW- 305 23335 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 90608ea (vertex names):
##  [1] 1005--1036 1005--104  1005--1040 1005--1047 1005--1076 1005--108 
##  [7] 1005--1097 1005--1101 1005--1104 1005--1125 1005--1132 1005--1139
## [13] 1005--1153 1005--1163 1005--1179 1005--1197 1005--121  1005--128 
## [19] 1005--135  1005--139  1005--141  1005--143  1005--144  1005--146 
## [25] 1005--147  1005--148  1005--149  1005--151  1005--152  1005--156 
## [31] 1005--157  1005--161  1005--162  1005--167  1005--170  1005--174 
## [37] 1005--177  1005--179  1005--185  1005--195  1005--201  1005--215 
## + ... omitted several edges

## IGRAPH f4db2a8 UNW- 58 592 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from f4db2a8 (vertex names):
##  [1] 1000--1002 1000--1017 1000--104  1000--121  1000--141  1000--146 
##  [7] 1000--174  1000--205  1000--234  1000--270  1000--342  1000--366 
## [13] 1000--381  1000--408  1000--411  1000--476  1000--508  1000--532 
## [19] 1000--575  1000--584  1000--597  1000--860  1000--911  1000--992 
## [25] 1002--141  1002--174  1002--205  1002--234  1002--381  1002--476 
## [31] 1002--532  1002--860  1002--911  1006--1007 1006--1017 1006--1178
## [37] 1006--312  1006--391  1006--532  1006--777  1006--911  1006--914 
## + ... omitted several edges

## IGRAPH 5dbffe3 UNW- 227 12411 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 5dbffe3 (vertex names):
##  [1] 1005--104  1005--1040 1005--1047 1005--108  1005--1097 1005--1101
##  [7] 1005--1104 1005--1125 1005--1132 1005--1139 1005--1153 1005--1163
## [13] 1005--1179 1005--1197 1005--121  1005--1225 1005--1240 1005--1245
## [19] 1005--1251 1005--1255 1005--128  1005--139  1005--141  1005--143 
## [25] 1005--144  1005--146  1005--147  1005--151  1005--152  1005--154 
## [31] 1005--156  1005--161  1005--162  1005--167  1005--174  1005--195 
## [37] 1005--205  1005--215  1005--223  1005--232  1005--233  1005--234 
## + ... omitted several edges

## IGRAPH 23d30e4 UNW- 61 536 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 23d30e4 (vertex names):
##  [1] 1005--1053 1005--1070 1005--1130 1005--1148 1005--1211 1005--146 
##  [7] 1005--177  1005--183  1005--223  1005--234  1005--264  1005--347 
## [13] 1005--354  1005--358  1005--366  1005--408  1005--411  1005--413 
## [19] 1005--476  1005--522  1005--563  1005--581  1005--626  1005--694 
## [25] 1005--777  1005--860  1005--914  1005--966  1040--1045 1040--1070
## [31] 1040--1148 1040--1151 1040--177  1040--183  1040--222  1040--234 
## [37] 1040--342  1040--347  1040--381  1040--408  1040--411  1040--413 
## + ... omitted several edges

## IGRAPH 005c312 UNW- 223 11391 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 005c312 (vertex names):
##  [1] 1005--1036 1005--104  1005--1040 1005--1076 1005--121  1005--135 
##  [7] 1005--143  1005--147  1005--148  1005--149  1005--151  1005--157 
## [13] 1005--167  1005--170  1005--179  1005--195  1005--201  1005--223 
## [19] 1005--230  1005--234  1005--249  1005--270  1005--285  1005--286 
## [25] 1005--306  1005--316  1005--323  1005--328  1005--33   1005--342 
## [31] 1005--343  1005--347  1005--358  1005--366  1005--381  1005--388 
## [37] 1005--392  1005--396  1005--398  1005--399  1005--404  1005--405 
## + ... omitted several edges

## IGRAPH 2566b1b UNW- 111 2441 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 2566b1b (vertex names):
##  [1] 1000--1002 1000--1005 1000--1017 1000--104  1000--1040 1000--1101
##  [7] 1000--1137 1000--121  1000--1253 1000--141  1000--146  1000--151 
## [13] 1000--174  1000--177  1000--183  1000--205  1000--222  1000--223 
## [19] 1000--234  1000--270  1000--342  1000--354  1000--366  1000--381 
## [25] 1000--391  1000--408  1000--411  1000--413  1000--476  1000--508 
## [31] 1000--532  1000--545  1000--570  1000--575  1000--581  1000--584 
## [37] 1000--597  1000--607  1000--681  1000--694  1000--76   1000--818 
## + ... omitted several edges

## IGRAPH 59a5bd0 UNW- 326 26359 -- 
## + attr: name (v/c), alias (v/c), nuclear (v/c), instance (v/c), color
## | (v/c), weight (e/n)
## + edges from 59a5bd0 (vertex names):
##  [1] 1005--1036 1005--104  1005--1040 1005--1047 1005--1076 1005--108 
##  [7] 1005--1097 1005--1101 1005--1104 1005--1125 1005--1132 1005--1139
## [13] 1005--1153 1005--1163 1005--1179 1005--1197 1005--121  1005--1225
## [19] 1005--1240 1005--1245 1005--1251 1005--1255 1005--128  1005--135 
## [25] 1005--139  1005--141  1005--143  1005--144  1005--146  1005--147 
## [31] 1005--148  1005--149  1005--151  1005--152  1005--154  1005--156 
## [37] 1005--157  1005--161  1005--162  1005--167  1005--170  1005--174 
## + ... omitted several edges

Index calculations

Using different packages we calculate the modularity and e-i index using nuclear as the attribute. for each period.

Modularity

Modularity measures coalition polarization. It ranges from 0 to 1.

  • Values close to 0 mean shows low ideological polarization between groups. And there differences within each coalition

  • Values close to 0.5 do not show any association.

  • Values close to 1 show high polarization between groups. Coalitions are compacted internally and show a great difference to others coalitions.

GraphName Modularity
g2014 NaN
g2015 0.0000000
g2016 0.3750000
g2017 0.0000000
g2018 0.1147922
g2019 0.2745192
g2020 0.1085868
g2021 0.1162112
g2022 0.1727056
g2023 0.1305927
gph1 0.1916591
gph2 0.1785657
gph3 0.1154407
gtnw 0.1794941
gttw 0.1660397
g2022nw 0.1598124
g2022tw 0.1787365
g2023nw 0.2132940
g2023tw 0.0961566
gph3nw 0.1045193
gph3tw 0.1743727

Average modularity is NaN

E-I index

E-i index measures homophily based on a given attribute, in this case we select attitude toward nuclear. E-I index ranges from −1 (represents complete homophilly) to 1 (represents complete heterophilly).

GraphName EIIndex
g2014 NaN
g2015 1.0000000
g2016 -1.0000000
g2017 -1.0000000
g2018 -1.0000000
g2019 -0.9699571
g2020 -0.8942189
g2021 -0.7253886
g2022 0.0103313
g2023 0.0831947
gph1 -0.7659574
gph2 -0.8012305
gph3 0.0940338
gtnw -0.2253052
gttw 0.0366402
g2022nw 0.0067568
g2022tw -0.0050761
g2023nw -0.0895522
g2023tw 0.0555702
gph3nw -0.1552642
gph3tw 0.0477636

Average EI index is NaN