-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathHW1_Q3.R
36 lines (32 loc) · 1.66 KB
/
HW1_Q3.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
library("igraph")
#####MAKING THE NETWORK
g1 <- aging.prefatt.game(1000, pa.exp=1, aging.exp=0, aging.bin=1000)
g2 <- aging.prefatt.game(1000, pa.exp=1, aging.exp=-1, aging.bin=1000)
g3 <- aging.prefatt.game(1000, pa.exp=1, aging.exp=-3, aging.bin=1000)
##### DEGREE DISTRIBUTION
barplot(degree.distribution(g1),main="Degree Distribution Histogram - G1(Aging.exp=0)")
plot(degree.distribution(g1),main="Degree Distribution Plot - G1(Aging.exp=0)")
barplot(degree.distribution(g2),main="Degree Distribution Histogram - G2(Aging.exp=-1)")
plot(degree.distribution(g2),main="Degree Distribution Plot - G2(Aging.exp=-1)")
barplot(degree.distribution(g3),main="Degree Distribution Histogram - G3(Aging.exp=-3)")
plot(degree.distribution(g3),main="Degree Distribution Plot - G3(Aging.exp=-3)")
#########APPLYYING FAST GREEDY COMMUNITY DETECTION ALGORITHM
ug1<- as.undirected(g1)
fg1<-fastgreedy.community(ug1)
hist(fg1$membership,breaks=50)
hist(fg1$modularity,breaks=50)
ug2<- as.undirected(g2)
fg2<-fastgreedy.community(ug2)
hist(fg2$membership,breaks=50)
hist(fg2$modularity,breaks=50)
ug3<- as.undirected(g3)
fg3<-fastgreedy.community(ug3)
hist(fg3$membership,breaks=50)
hist(fg3$modularity,breaks=50)
###### PLOTTING TH COMMUNITY SIZE DISTRIBUTION
ctm1 = community.to.membership(g1, fg1$merges, step=which.max(fg1$modularity)-1)
barplot(table(ctm1$csize),main="Community Size - G1(Aging.exp=0)")
ctm2 = community.to.membership(g2, fg2$merges, step=which.max(fg2$modularity)-1)
barplot(table(ctm2$csize),main="Community Size - G2(Aging.exp=-1)")
ctm3 = community.to.membership(g3, fg3$merges, step=which.max(fg3$modularity)-1)
barplot(table(ctm3$csize),main="Community Size - G3(Aging.exp=-3)")