Transitivity:
### TRANSITIVITY ####
doTransitivity = function(network) {
trs = transitivity(network, type = 'local', vids = V(network)$name)
V(network)$transitivity = trs
return(V(network)$transitivity)
}
mynet = doNetwork(node, edge)
doGraph(mynet, 'discipline_classification')

# doTransitivity(mynet)
# Visualizing Transitivity
trs1 = round(transitivity(mynet, type='local'), 5)
trs_top25 = head(sort(trs1, decreasing=TRUE), length(trs1)*.25)
plot(trs_top25,
main='Transitivity Top 25 Percentile',
xlab='Nodes (Descending)',
ylab='Transitivity',
pch=19,
col = wes_palette('Zissou1')
)

trs_top50 = head(sort(trs1,decreasing=TRUE),length(trs1)*.50)
plot(trs_top50,
main='Transitivity Top 50 Percentile',
xlab='Nodes (Descending)',
ylab='Transitivity',
pch=19,
col = wes_palette('GrandBudapest2', n=4)
)

Triad Census:
# Triad Census
# Triad Census
triads=as.array(graph.motifs(mynet,size=3)[-2][-1])
print(paste("Triads:",triads))
## [1] "Triads: 12564" "Triads: 774"
Degree Distribution:
# Degree Distribution
mynet.degrees = degree(mynet)
# Let's count the frequencies of each degree
mynet.degree.histogram <- as.data.frame(table(mynet.degrees))
# Need to convert the first column to numbers, otherwise
# the log-log thing will not work (that's fair...)
mynet.degree.histogram[,1] <- as.numeric(mynet.degree.histogram[,1])
# Now, plot it!
ggplot(mynet.degree.histogram, aes(x = mynet.degrees, y = Freq)) +
geom_point() +
scale_x_continuous("Degree\n(nodes with this amount of connections)",
breaks = c(1, 3, 10, 30, 100, 300),
trans = "log10") +
scale_y_continuous("Frequency\n(how many of them)",
breaks = c(1, 3, 10, 30, 100, 300, 1000),
trans = "log10") +
ggtitle("Degree Distribution (log-log)") +
geom_point()

Subgroup Analysis: Cliques
#### SUBGROUP ANALYSIS:
cliques = largest.cliques(mynet)
cliques1 = cliques[[1]]
cliques_color = wes_palette('GrandBudapest2')
mynetCliques = induced.subgraph(graph=mynet, vids=cliques1)
degree(mynetCliques)
## Harrison, Stephen C Chazin, Walter J Anderson, Karen S
## 8 9 8
## Blacklow, Stephen C Rapoport, Tom A Otwinowski, Zbyszek
## 10 8 10
## Rosen, Michael K Eck, Michael J Wu, Hao
## 11 11 9
plot(mynetCliques,
main='Network Cliques',
vertex.color=cliques_color,
layout=layout.fruchterman.reingold(mynetCliques),
vertex.size=V(mynetCliques)*6
)

clust = cluster.distribution(mynet)