igraph-help
[Top][All Lists]

[igraph] Stanford SNA lab-3 : Error in exercise

 From: pranav nerurkar Subject: [igraph] Stanford SNA lab-3 : Error in exercise Date: Wed, 24 May 2017 12:24:53 +0530

0 down vote favorite

I am following this lab exercise on community detection https://sna.stanford.edu/lab.php?l=3

since in their program community.to.membership was deprecated i modified their code. Original code is at https://sna.stanford.edu/lab.php?l=3 Line 251 onwards.

My code:
``````library(sna)

ideal_observed_cors = vector()

for (i in 0:(num_vertices-1)) {
num_comms = (num_vertices - i)
cat('number of communities: ', num_comms, '\n')
community <- list(cutat(wc, steps=i)) //replaced community.to.membership with cutat
names(community)=c("membership")
print(community)
idealized_comm_mat <- matrix(nrow=num_vertices, ncol=num_vertices)

for (m in 1:num_vertices) {
for (n in 1:num_vertices) {
if (m==n) {
idealized_comm_mat[m,n] = 0
} else if (community\$membership[m] == community\$membership[n]) {
idealized_comm_mat[m,n] = 1
} else {
idealized_comm_mat[m,n] = 0
}
}
}
print(idealized_comm_mat)

if (num_comms > 1 & num_comms < num_vertices) {
print(ideal_observed_cors[length(ideal_observed_cors)])
} else {
ideal_observed_cors <- append(ideal_observed_cors, 0)
print('unable to calcuate correlation; setting value to 0')
}
cat('\n')
}
ideal_observed_cors <- rev(ideal_observed_cors)
ideal_observed_cors
plot(ideal_observed_cors)``````

But i am getting error

number of communities: 105 [1] "unable to calcuate correlation; setting value to 0"

number of communities: 104 Error in as.sociomatrix.sna(dat2) : as.sociomatrix.sna input must be an adjacency matrix/array, network, or list.

--

Warm and Kind regards,

Pranav .A.Nerurkar
Student
Dept of Computer Engineering
Veermata Jijabai Technological Institute
Matunga, Mumbai, Maharashtra.
Ph: 9619997797