Skip to content

Commit

Permalink
sparse matrix is now never converted into non-sparse, solving issues_15
Browse files Browse the repository at this point in the history
  • Loading branch information
WeijiaZhang24 authored and mattiat committed Mar 6, 2020
1 parent 5ecc934 commit b775c49
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions .src/R1_code/sub-challenge1/mlrmcl_r4_v2.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,25 @@ preProcessing <- function(input,method=c("quantile","pageRank","double"),i,integ

generateFile <- function(graph,weighted=T){
test3<-get.adjacency(graph,attr = "weight")
m<-as.matrix(test3)
m.index<-apply(m!=0,1,which,arr.ind=T)
# weight<-m[m.index]
m.index<-get.adjlist(graph)
graph_directed <- as.directed(graph)
m.weight <- get.edge.attribute(graph_directed,name = "weight")
# m<-as.matrix(test3)
if (weighted){
test<-sapply(1:nrow(m), function(i) m[i,m.index[[i]]])
# test<-sapply(1:nrow(m), function(i) m[i,m.index[[i]]])
temp2<-list()
# temp2_t <- list()
count <- 1
for (i in 1:length(m.index)){
temp2[[i]]<-c(rbind(as.character(m.index[[i]]),test[[i]]))
num_edge_i = length(m.index[[i]])
if (num_edge_i == 0){
temp2[[i]]<-c(rbind(as.character(m.index[[i]]),numeric(0)))
} else{
edge_weight_i <- m.weight[count:(count+num_edge_i-1)]
# temp2_t[[i]]<-c(rbind(as.character(m.index[[i]]),test[[i]]))
temp2[[i]]<-c(rbind(as.character(m.index[[i]]),edge_weight_i))
count <- count + num_edge_i
}
}
fn <- "test.txt"
if (file.exists(fn)) file.remove(fn)
Expand All @@ -129,7 +140,8 @@ generateFile <- function(graph,weighted=T){

}

postProcessing <- function(method=c("random","discard","recluster"),smallest = 3,largest=100,g=graph,b2,c2,i2){
postProcessing <- function(method=c("random","discard","recluster"),smallest = 3,largest=100,
g=graph,b2,c2,i2){
result<-read.table("output.txt")
output<-list()
# for (i in 1:nrow(unique(result))){
Expand Down

0 comments on commit b775c49

Please sign in to comment.