library(igraph)
##
## Attaching package: 'igraph'
## The following objects are masked from 'package:stats':
##
## decompose, spectrum
## The following object is masked from 'package:base':
##
## union
Initial.matrix <- read.csv("/Users/hanmengwang/Library/Mobile Documents/com~apple~CloudDocs/Master_Course_Materials/0HM220 Network Society/Assignment invisible work/con_info1-1.csv",header = TRUE, row.names=1, check.names = FALSE,na.strings="")
matrix <- as.matrix(Initial.matrix)
GInfo <- graph.adjacency(matrix, mode="directed", weighted=TRUE)
ecount(GInfo)
## [1] 879
is.simple(GInfo)
## [1] FALSE
sGInfo <- igraph::simplify(GInfo)
is.simple(sGInfo)
## [1] TRUE
ecount(sGInfo)
## [1] 877
sGInfo$name <- "Information network"
I found that there are 879 edges in the information network. However, there exist self-loops or multiple relations in the network. After simplifying the network, there are 877 edges.
sGdensity <- edge_density(sGInfo)
1 - sGdensity
## [1] 0.5763285
The possibility of one employee knows another employee is the edge density of this network. After subtracting edge density from 1, I find that there is 57.63% chance that an employee does not know another employee.
#Generate the subgraph with weight = 4, 5
d = E(sGInfo)$weight > 3
v <- rep(1:ecount(sGInfo))
g <- v[d==TRUE]
sGInfo_strong <- subgraph.edges(sGInfo, g, delete.vertices = FALSE)
#### Plot the subgraph ====
set.seed(123)
lfr<-layout.fruchterman.reingold(sGInfo_strong)
par(mar = c(0, 0, 2, 0)) # Set the margin: bottom, left, top, right
plot(sGInfo_strong,
layout = lfr,
edge.curved=.2,
edge.arrow.size=.3,
edge.color="#757575",
vertex.label.cex=.6,
vertex.size=7,
vertex.color="#D4CF8A",
vertex.frame.color="#212121",
vertex.label.color="#212121",
vertex.label.dist=0,
asp=0.6)
mtext("Information network of employees with strong ties", side = 3, line = 1, cex = 1)
mtext("(Weight = 4 or 5)", side = 3, cex = .8)
It is clear that some people are likely to be equal or more often asked for information or advice, such as person 28, 29. Some people like person 9, 15, or 41 are only asked for advice equal or more than often but they do not reach out to others. There are also several people who are neither asked for advice nor ask people for advice that often, such as person 16, 24, 30, 37, and 43.
nodes_location <- read.csv("/Users/hanmengwang/Library/Mobile Documents/com~apple~CloudDocs/Master_Course_Materials/0HM220 Network Society/Assignment invisible work/con_location-1.csv",header=T, as.is=T)
nodes_level <- read.csv("/Users/hanmengwang/Library/Mobile Documents/com~apple~CloudDocs/Master_Course_Materials/0HM220 Network Society/Assignment invisible work/con_org_level-1.csv",header=T, as.is=T)
nodes_gender <- read.csv("/Users/hanmengwang/Library/Mobile Documents/com~apple~CloudDocs/Master_Course_Materials/0HM220 Network Society/Assignment invisible work/con_gender-1.csv",header=T, as.is=T)
V(sGInfo)$location = nodes_location$location
V(sGInfo)$level = nodes_level$level
V(sGInfo)$gender = nodes_gender$gender
#1: Boston; 2: London; 3: Paris; 4: Rome; 5: Madrid; 6: Oslo; 7: Copenhagen
color <- c("#7CCC91","#8598D3", "#DA8FC6", "#E0CE99", "#B582D7", "#44C1B6", "#4F85C5")
V(sGInfo_strong)$color <- color[V(sGInfo)$location]
par(mar = c(3, 0, 2, 0)) # Set the margin: bottom, left, top, right
plot(sGInfo_strong,
layout = lfr,
edge.curved=.2,
edge.arrow.size=.3,
edge.color="#757575",
vertex.label.cex=.6,
vertex.size=7,
vertex.frame.color="#212121",
vertex.label.color="#212121",
vertex.label.dist=0,
asp=0.6)
mtext("Information network of employees with strong advice ties", side = 3, line = 1, cex = 1)
mtext("Partioned by location of employees", side = 3, cex = .8)
legend(x=-0.6, y=-1.2, c("Boston","London","Paris", "Rome", "Madrid", "Oslo", "Copenhagen"), pch=21,
col="#777777", pt.bg=color, pt.cex=1.4, cex=.7, bty="n", ncol=6)
It is very clear that, besides several isolated employees, many employees form their own clustering groups based on their location. Boston network is the biggest sub-network in this graph. It is also clear that employees from Boston don’t have too much interactions with the other groups of different locations.
#Information network with strong ties
dyad_census(sGInfo_strong)
## $mut
## [1] 55
##
## $asym
## [1] 58
##
## $null
## [1] 922
reciprocity(sGInfo_strong)
## [1] 0.6547619
The advice relationship could be seen as reciprocal (65.48%). We could say that there is a 65.48% chance that people you often ask advice for might ask for your advice often. For the rest, one explanation is that people with a lower organizational level asking for seniors advice often, but seniors don’t ask for the advice in return.
total <- triad.census(sGInfo_strong)
percentage <- round(total/sum(total), digit=3)
type <-list("A,B,C, the empty graph",
"A->B, C, the graph with a single directed edge",
"A<->B, C, the graph with a mutual connection between two vertices",
"A<-B->C, the out-star.",
"A->B<-C, the in-star.",
"A->B->C, directed line.",
"A<->B<-C",
"A<->B->C",
"A->B<-C, A->C",
"A<-B<-C, A->C",
"A<->B<->C",
"A<-B->C, A<->C",
"A->B<-C, A<->C",
"A->B->C, A<->C",
"A->B<->C, A<->C",
"A<->B<->C, A<->C, the complete graph.")
tr <- cbind(type, total, percentage)
tr
## type total
## [1,] "A,B,C, the empty graph" 10811
## [2,] "A->B, C, the graph with a single directed edge" 1991
## [3,] "A<->B, C, the graph with a mutual connection between two vertices" 1891
## [4,] "A<-B->C, the out-star." 51
## [5,] "A->B<-C, the in-star." 24
## [6,] "A->B->C, directed line." 43
## [7,] "A<->B<-C" 80
## [8,] "A<->B->C" 106
## [9,] "A->B<-C, A->C" 13
## [10,] "A<-B<-C, A->C" 1
## [11,] "A<->B<->C" 67
## [12,] "A<-B->C, A<->C" 3
## [13,] "A->B<-C, A<->C" 10
## [14,] "A->B->C, A<->C" 12
## [15,] "A->B<->C, A<->C" 47
## [16,] "A<->B<->C, A<->C, the complete graph." 30
## percentage
## [1,] 0.712
## [2,] 0.131
## [3,] 0.125
## [4,] 0.003
## [5,] 0.002
## [6,] 0.003
## [7,] 0.005
## [8,] 0.007
## [9,] 0.001
## [10,] 0
## [11,] 0.004
## [12,] 0
## [13,] 0.001
## [14,] 0.001
## [15,] 0.003
## [16,] 0.002
#One employee advises the two others (no reciprocal)
percentage[4] + percentage[9]
## [1] 0.004
#Two employees advise the third employee (no reciprocal)
percentage[5] + percentage[9]
## [1] 0.003
For strong advice relations, it is likely that there is a very little difference between one employee advises the two others rather than the reverse (0.4% ≈ 0.3%). No matter it is one employee advising the two others, or two employees advise the third employee, it all implies a structural equivalence (within the two others and within the two employees). And this structural equivalence is quite balanced for these two situations. This equivalence is based on their tendency to receive / provide information from / to the alters. It is different from what the last second question proposed, which is based on their value to the alters.
This result also suggests that within this company, perhaps there is no peer mentoring program implemented yet, otherwise the percentage will certainly be affected. For example, if there are multiple employees directed by one mentor, the first triad percentage will possibly be higher than the second triad.
In addition, I also found that the percentage of empty triad is very high, which implies there leaves a room for more informational relations in the network.
#### Check whether the network is a small world. Simulate 1000 random networks
ntrials <- 1000
nv <- vcount(sGInfo)
ne <- ecount(sGInfo)
# here a list is created in which the sampling results are stored
cl.rg <- numeric(ntrials)
apl.rg <- numeric(ntrials)
for (i in (1:ntrials)) {
g.rg <- sample_gnm(nv, ne, directed=FALSE)
cl.rg[i] <- transitivity(g.rg)
apl.rg[i] <- mean_distance(g.rg)
}
coefficient <- (transitivity(sGInfo, type=c("undirected"))/mean(cl.rg))/(mean_distance(sGInfo, directed=FALSE)/mean(apl.rg))
coefficient
## [1] 0.5769015
diameter(sGInfo, directed = FALSE)
## [1] 2
#### Modularity
modularity(sGInfo,V(sGInfo)) #Bad grouping in total
## [1] -0.02385166
Although the diameter of this network is 2, meaning that it only requires two steps to get from one side to another, this information network can not be taken as a small world (σ=0.58<1). It is not very clustered. It could also be seen from the modularity score (-0.024). The result indicates that the Boston information network does not have a good balance between local clustering and global connectivity. The network is not well-suited for efficient communication and sharing of advice or information among its members.
#Use edge betweenness algorithm
ceb <- cluster_edge_betweenness(as.undirected(sGInfo))
## Warning in cluster_edge_betweenness(as.undirected(sGInfo)): At
## core/community/edge_betweenness.c:493 : Membership vector will be selected
## based on the highest modularity score.
## Warning in cluster_edge_betweenness(as.undirected(sGInfo)): At
## core/community/edge_betweenness.c:500 : Modularity calculation with weighted
## edge betweenness community detection might not make sense -- modularity treats
## edge weights as similarities while edge betwenness treats them as distances.
modularity(ceb) #0.16
## [1] 0.1553098
#Use louvain / multi-level algorithm
ceba <- cluster_louvain(as.undirected(sGInfo))
modularity(ceba) #0.33
## [1] 0.3337488
plot(
ceba,
as.undirected(sGInfo),
vertex.label.cex=.6,
edge.arrow.size=.2,
edge.width=.4,
edge.color="#757575",
)
mtext("Information network clusters in total", side = 3, line = 1, cex = 1)
mtext("Use louvain algorithm", side = 3, cex = .8)
After applying the edge-betweenness algorithm to separate different clusters in the network, the information network becomes more clustered within each group (modularity=0.16). Modularity is even better when using Louvain’s algorithm (modularity = 0.33). The seperated clusters applying Louvain’s algorithm are shown above. Modularity off 0.33 indicates that the network is moderately divided into communities or modules by the multi-level algorithm. Combined with the interpretation given above, this division suggests that although the information network is not closely connected, this network does form some clusters or groups.
#### Subgraph====
sGInfo_Boston <- induced.subgraph(sGInfo, vids=which(V(sGInfo)$location==1))
#### Drop the isolates====
m <- components(sGInfo_Boston)
m <- unlist(m$membership)
sGInfo_Boston2 <- induced.subgraph(sGInfo_Boston, vids=which(m==1))
#Include organizational level: 1 Research Assistant; 2: Junior Consultant; 3: Senior Consultant; 4: Managing Consultant; 5: Partner
color <- c("#4787C2","#CFB86E", "#89D071", "#CB7E62", "#CBABE3")
V(sGInfo_Boston2)$color <- color[V(sGInfo_Boston2)$level]
set.seed(123)
lfr<-layout.fruchterman.reingold(sGInfo_Boston2)
par(mar = c(3, 0, 2, 0)) # Set the margin: bottom, left, top, right
plot(as.undirected(sGInfo_Boston2),
vertex.size=degree(sGInfo_Boston2)^1.05*0.6,
vertex.label.cex=.8,
vertex.frame.color="#212121",
vertex.label.color="#212121",
edge.curved=.2,
edge.width=.4,
edge.color="#757575",
layout = lfr
)
mtext("Information network of employees from Boston without isolates", side = 3, line = 1, cex = 1)
mtext("Partioned by organizational level, scaled by degree centrality", side = 3, cex = .8)
legend(x=-1.2, y=-1.2, c("Research Assistant","Junior Consultant","Senior Consultant", "Managing Consultant", "Partner"), pch=21,
col="#777777", pt.bg=color, pt.cex=1.2, cex=.8, bty="n", ncol=2)
It is very clear that information tends to aggregate inside people with
higher organizational levels. People like managing consultants, partners
are generally more likely to have rich information accumulated or
sent.
#### Number of edges from inter and intra-group =====
#G1=male, G2=female
G1 <- V(sGInfo_Boston2)[gender==1]
G2 <- V(sGInfo_Boston2)[gender==2]
e <- rep(0, ecount(sGInfo_Boston2))
E(sGInfo_Boston2)$group = e
E(sGInfo_Boston2)[ G1 %--% G1 ]$group <- 1 # %--% selects all edges between two sets of vertices.
E(sGInfo_Boston2)[ G2 %--% G2 ]$group <- 2
E(sGInfo_Boston2)[ G1 %--% G2 ]$group <- 3
table(E(sGInfo_Boston2)$group) #This table show the number of edges
##
## 1 2 3
## 239 24 155
perc <- table(E(sGInfo_Boston2)$group)/sum(table(E(sGInfo_Boston2)$group)) # This table show the percentage of the number of edges to the total
type <- list("male-male","female-female", "male-female")
t<-cbind(type, perc)
knitr::kable(t, "simple")
| type | perc |
|---|---|
| male-male | 0.57177033492823 |
| female-female | 0.0574162679425837 |
| male-female | 0.370813397129187 |
#### Bridges in information network and Boston network====
articulation_points(sGInfo_Boston2)
## + 0/24 vertices, named, from 7189e84:
bridges(sGInfo_Boston2)
## + 0/418 edges from 7189e84 (vertex names):
a <- articulation_points(sGInfo_strong)
b <- bridges(sGInfo_strong)
a
## + 5/46 vertices, named, from 9fa5428:
## [1] 3 22 34 38 8
b
## + 4/168 edges from 9fa5428 (vertex names):
## [1] 3 ->9 22->15 38->41 10->8
It means that 57.2% of the information edges are within males, and 37.1% of the information edges are between males and females. Only 5.7% of the edges are within the female group. It shows there is no disconnect between males and females in general, the inter-percentage is rather large. The same conclusion can also be decided from the number of bridges and articulation points of the network. There is no disconnect in information flows between males and females in both information network in total and Boston information network, which is good news for knowledge-sharing in the network. It indicates that at least in Boston network gender is not the concern that cause segregation.
par(mfrow=c(1,2))
cohesion(sGInfo_Boston2)
## [1] 4
vcount(sGInfo_Boston2)
## [1] 24
The structural cohesion of the Boston network is 4. It means that the Boston network is well connected. Only by removing at least 4 vertex, the Boston network would become disconnected. The redundancy built inside the network makes it not as vulnerable as a network with lower cohesion value and is beneficial to remain the network’s functionality and efficiency.
But considering this network has 24 employees, it doesn’t imply that it is a extremely cohesive network either.
clique.number(as.undirected(sGInfo_Boston2))
## [1] 15
count_max_cliques(as.undirected(sGInfo_Boston2), min=15)
## [1] 8
clique_size_counts(as.undirected(sGInfo_Boston2))
## [1] 24 235 1304 4717 11997 22436 31692 34311 28606 18279 8812 3107
## [13] 757 114 8
vcount(sGInfo_Boston2)
## [1] 24
In most social networks the upper limit of the size of a single clique is seven (Killworth and Bernard, 1974). But in Boston subgraph, the clique size is 15, and there are 8 cliques like this. It implies that many smaller well-connected groups inside this network. People rely on such cliques to quickly exchange information. Note that there are only 24 members in the Boston network after removing the isolated ones. Hence, it is a very high chance for an employee to be inside a closely-knit clique if he or she were located in Boston.
between<-betweenness(sGInfo_Boston2)
degr<-degree(sGInfo_Boston2)
eigen<-eigen_centrality(sGInfo_Boston2)$vector
#### Plot (betweenness)====
set.seed(123)
kk <- layout_with_kk(sGInfo_Boston2)
# Assign colors according to the degree score
fine = 500
pal = colorRampPalette(c("#3B8592","#4295A5", "#49A6B7", "#5AB0BF","#6CB9C7", "#7EC2CE", "#90CBD6", "#A3D4DD", "#B5DDE4", "#C7E5EB"))
graphCol_btw = pal(fine)[as.numeric(cut(degr, breaks=fine))]
par(mar = c(0, 0, 2, 0)) # Set the margin: bottom, left, top, right
plot(as.undirected(sGInfo_Boston2),
vertex.size=(between^0.35)*8,
vertex.label.cex=.7,
vertex.frame.color="#212121",
vertex.label.color="#212121",
vertex.color = graphCol_btw,
edge.curved=.2,
edge.width=.4,
edge.color="#757575",
layout = kk
)
mtext("Information network of employees from Boston without isolates", side = 3, line = 1, cex = 1)
mtext("Scaled by betweenness centrality", side = 3, cex = .8)
#### Plot(degree)====
set.seed(123)
kk <- layout_with_kk(sGInfo_Boston2)
# Assign colors according to the degree score
graphCol_dgr = pal(fine)[as.numeric(cut(degr, breaks=fine))]
par(mar = c(0, 0, 2, 0)) # Set the margin: bottom, left, top, right
plot(as.undirected(sGInfo_Boston2),
vertex.size=degr^1.8*.04,
vertex.label.cex=.7,
vertex.color=graphCol_dgr,
vertex.frame.color="#212121",
vertex.label.color="#212121",
edge.curved=.2,
edge.width=.4,
edge.color="#757575",
layout = kk
)
mtext("Information network of employees from Boston without isolates", side = 3, line = 1, cex = 1)
mtext("Scaled by degree centrality", side = 3, cex = .8)
#### Plot (eigen_vector)====
# Assign colors according to the degree score
graphCol_eigen = pal(fine)[as.numeric(cut(degr, breaks=fine))]
par(mar = c(0, 0, 2, 0)) # Set the margin: bottom, left, top, right
plot(as.undirected(sGInfo_Boston2),
vertex.size=eigen*40,
vertex.label.cex=.7,
vertex.frame.color="#212121",
vertex.label.color="#212121",
vertex.color=graphCol_eigen,
edge.curved=.2,
edge.width=.4,
edge.color="#757575",
layout = kk
)
mtext("Information network of employees from Boston without isolates", side = 3, line = 1, cex = 1)
mtext("Scaled by eigenvector centrality", side = 3, cex = .8)
The network scaled by different centrality scores is shown above.
btw_list<-c(between)
head(sort(btw_list, decreasing = TRUE), 5)
## 13 29 27 38 17
## 106.77442 35.22175 30.78890 26.44614 23.73440
degr_list<-c(degr)
head(sort(degr_list, decreasing = TRUE), 5)
## 20 26 28 45 6
## 43 42 42 42 41
eigen_list<-c(eigen)
head(sort(eigen_list, decreasing = TRUE), 5)
## 26 45 19 6 20
## 1.0000000 0.9794605 0.9624703 0.9624271 0.8476480
####Reserve for the intervention, not for this question====
head(sort(c(betweenness(sGInfo)), decreasing = TRUE), 5)
## 34 12 22 16 13
## 179.0669 176.3596 133.9233 119.9499 108.8191
head(sort(c(degree(sGInfo)), decreasing = TRUE), 5)
## 20 12 2 22 45
## 65 63 61 60 60
head(sort(c(eigen_centrality(sGInfo)$vector), decreasing = TRUE), 5)
## 45 26 20 19 6
## 1.0000000 0.9695663 0.9622076 0.9314651 0.9158245
In terms of power through brokerage and access to information, person number 13 has the highest power in the Boston network. Then 29, 27, 38, 17 accordingly. It utilizes betweenness centrality as a measurement, and its betweenness is much higher than the rest. In terms of access to resources, person number 20, 26, 28, 45, 6 are all very powerful. Here it utilizes degree centrality as a measurement, which does not differ very much. In respect to access to resources of powerful others, person 26, 45, 19, 6, 20 are powerful.Eigenvector centrality is used to measure it. 26 is higher than the rest evidently. Thus, if we consider access to information in this information network in Boston, then number 13 is clearly the most prominent one, connecting many different groups. If we take the acccess to resources in general and resources of powerful others, then number 26 is the most prominent person with the highest degree and eigenvector centrality combined.
#### Import the information network====
Initial.matrix <- read.csv("/Users/hanmengwang/Library/Mobile Documents/com~apple~CloudDocs/Master_Course_Materials/0HM220 Network Society/Assignment invisible work/con_value2-1.csv",header = TRUE, row.names=1, check.names = FALSE,na.strings="")
matrix <- as.matrix(Initial.matrix)
GValue <- graph.adjacency(matrix, mode="directed", weighted=TRUE)
GValue$name <- "Value network"
#### Simplify====
is.simple(GValue)
## [1] FALSE
sGValue <- igraph::simplify(GValue)
is.simple(sGValue)
## [1] TRUE
#### Reserve the edges with weight = 5 =====
#weight = 5
d = E(sGValue)$weight == 5
v <- rep(1:ecount(sGValue))
g <- v[d==TRUE]
sGValue_strong <- subgraph.edges(sGValue, g, delete.vertices = FALSE)
total <- triad.census(sGValue_strong)
percentage <- round(total/sum(total), digit=3)
type <-list("A,B,C, the empty graph",
"A->B, C, the graph with a single directed edge",
"A<->B, C, the graph with a mutual connection between two vertices",
"A<-B->C, the out-star.",
"A->B<-C, the in-star.",
"A->B->C, directed line.",
"A<->B<-C",
"A<->B->C",
"A->B<-C, A->C",
"A<-B<-C, A->C",
"A<->B<->C",
"A<-B->C, A<->C",
"A->B<-C, A<->C",
"A->B->C, A<->C",
"A->B<->C, A<->C",
"A<->B<->C, A<->C, the complete graph.")
tr <- cbind(type, total, percentage)
tr
## type total
## [1,] "A,B,C, the empty graph" 8574
## [2,] "A->B, C, the graph with a single directed edge" 4169
## [3,] "A<->B, C, the graph with a mutual connection between two vertices" 1307
## [4,] "A<-B->C, the out-star." 234
## [5,] "A->B<-C, the in-star." 206
## [6,] "A->B->C, directed line." 173
## [7,] "A<->B<-C" 84
## [8,] "A<->B->C" 142
## [9,] "A->B<-C, A->C" 105
## [10,] "A<-B<-C, A->C" 0
## [11,] "A<->B<->C" 19
## [12,] "A<-B->C, A<->C" 11
## [13,] "A->B<-C, A<->C" 69
## [14,] "A->B->C, A<->C" 12
## [15,] "A->B<->C, A<->C" 40
## [16,] "A<->B<->C, A<->C, the complete graph." 35
## percentage
## [1,] 0.565
## [2,] 0.275
## [3,] 0.086
## [4,] 0.015
## [5,] 0.014
## [6,] 0.011
## [7,] 0.006
## [8,] 0.009
## [9,] 0.007
## [10,] 0
## [11,] 0.001
## [12,] 0.001
## [13,] 0.005
## [14,] 0.001
## [15,] 0.003
## [16,] 0.002
#One employee values the two others
percentage[4] + percentage[9]
## [1] 0.022
#Two employees value the third employee
percentage[5] + percentage[9]
## [1] 0.021
From the triad census above, we could see that there is not much a difference between the two relations (2.2% ≈ 2.1%). Similar to the information network, this results suggests that “I am valuable to two others on their work” and “Two other employees are valuable to my work” occupy a similar percentage. The same as the sixth question, “two others” holds the equivalent structural position to each other, and so does “two other employees”. These two sets of relations are rather balanced to the ego.
The percentage of such triads here, however, is higher than the percentage in the information network. It means that people are more likely to confirm the valuable and utilitarian relations compared to build the beneficial information exchange relations with one another in the one-to-two or two-to-one triads.