-
Notifications
You must be signed in to change notification settings - Fork 0
/
Zachary Karate Club.R
161 lines (87 loc) · 2.49 KB
/
Zachary Karate Club.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
library("igraph")
install.packages("igraphdata")
install.packages("tidyverse")
library("igraphdata")
data(karate)
plot(karate)
V(karate)
gorder(karate)
plot(layout_in_circle(karate))
#degree distribution
degree(karate)
degree.distribution(karate)
plot(degree.distribution(karate))
library("utils")
plot_dd(karate)
which.max(degree(karate))
which.min(degree(karate))
sort(degree(karate))
tail(sort(degree(karate)))
#network centrality analysis
closeness(karate)
deg = degree(karate,mode = "all")
hist(deg)
betweenness(karate)
edge_betweenness(karate)
eigen_centrality(karate)
install.packages("network")
#Average Path Length
a = average.path.length(karate)
print(a)
#clustering coefficient
transitivity(karate)
#degree distribution
dlist = degree.distribution(karate,mode = "all",cumulative = T)
plot(x = 0:max(deg),y = dlist, pch = 16,cex = 1.2, col = c(1:20),xlab = "Degree",ylab = "Cumulative Frequency")
lines(x = 0:max(deg),y = dlist, col = "blue")
#community detection
club1 = cluster_label_prop(karate) #label based propagation
plot(club1,karate)
club2 = cluster_edge_betweenness(karate) #edge based propagation
plot(club2,karate)
club3 = cluster_fast_greedy(as.undirected(karate)) #modularity optimization
plot(club3,as.undirected(karate))
club3
club2
club1
#Network Cohesion
transitivity(karate) #clustering coefficient
edge_density(karate)
clique_num(karate)
#Kite
data(kite)
plot(kite)
which.max(degree(kite))
which.max(closeness(kite))
which.max(edge_betweenness(kite))
#koenisberg
data(Koenigsberg)
k =Koenigsberg
plot(k)
#yeast
data(yeast)
#Vertex Centrality
# 1 degree distribution
which.max(degree(yeast))
which.min(degree(yeast))
plot(degree.distribution(yeast))
# 2 Closeness
which.max(closeness(yeast))
which.min(closeness(yeast))
plot(closeness(yeast))
# 3 edge between ness
which.max(edge_betweenness(yeast))
which.min(edge_betweenness(yeast))
plot(edge_betweenness(yeast))
# eigen centrality
# Network Cohesion
transitivity(yeast) #clustering coefficient
edge_density(yeast)
clique_num(yeast)
#Community Discovery
club.1 = cluster_edge_betweenness(yeast) #Edge betweeness based
plot(club.1,yeast)
club.2 = cluster_label_prop(yeast) #label based propagation
plot(club.2,yeast)
clug = cluster_fast_greedy(as.undirected(yeast)) #modularity optimization
plot(clug,as.undirected(yeast))