Hello,

I am new to igraph (and R for that matter) and have come across a problem
I've been unable solve. I am trying to implement the algorithm in this
<https://arxiv.org/abs/q-bio/0611020> paper (see bottom of pg. 3). In
brief, the algorithm is a way to explore the assortativity-clustering space
of a network. This is done by using degree distribution-preserving rewiring
to alter assortativity and clustering levels in a given network. The idea
is then to measure some outcomes (e.g., robustness) at different points or
"pixels" in the assortativity-clustering space and see how the observed
network compares to outcomes associated with different assortativity and
clustering levels.

The procedure is computationally intensive so I am running it in parallel
on a Linux-based high-powered computer running R version 3.4.1 and igraph
version 1.1.0 (system specs here
<https://www.american.edu/cas/hpc/software.cfm>). Note that we had some
difficulties installing igraph on the machine and the system administrator
resorted to installing a dev version. When running my code I run into two
types of errors. The first is "Error: cons memory exhausted (limit
reached?)." The memory available should be sufficient for this job, so I am
not sure what is going on here. The second error is a bit more concerning:

 *** caught segfault ***
address 0x1, cause 'memory not mapped'

Traceback:
 1: .Call("R_igraph_finalizer", PACKAGE = "igraph")
 2: with$fun(list(119, FALSE, c(110, 73, 80, 21, 94, 104, 102, 57, 99, 73,
57, 60, 59, 55, 82, 40, 38, 107, 111, 57, 80, 108, 53, 93, 100, 104, 107,
114, 73, 104, 85, 111,

[TEXT REMOVED TO SAVE SPACE]

"100", "101", "102",     "103", "104", "105", "106", "107", "108", "109",
"110", "111",     "112", "113", "114", "115", "116", "117", "118",
"119")),         list()), <environment>), loops = FALSE, niter = 1)
 3: eval(call, .env)
 4: eval(call, .env)
 5: do_call(with$fun, list(graph), .args = with$args)
 6: rewire(ntw1, with = keeping_degseq(loops = FALSE, niter = 1))
 7: sampling(network, pixels, min.r, max.r, min.c, max.c, vrnd)
 8: FUN(X[[i]], ...)
 9: lapply(X = S, FUN = FUN, ...)
10: doTryCatch(return(expr), name, parentenv, handler)
11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
12: tryCatchList(expr, classes, parentenv, handlers)
13: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if
(!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))
         call <- sys.call(-4L)        dcall <- deparse(call)[1L]
prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        msg <-
conditionMessage(e)        sm <- strsplit(msg, "\n")[[1L]]        w <- 14L
+ nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))
           w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],
   type = "b")        if (w > LONG)             prefix <- paste0(prefix,
"\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix,
conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if
(!silent && identical(getOption("show.error.messages"),         TRUE)) {
    cat(msg, file = outFile)        .Internal(printDeferredWarnings())
}    invisible(structure(msg, class = "try-error", condition = e))})
14: try(lapply(X = S, FUN = FUN, ...), silent = TRUE)
15: sendMaster(try(lapply(X = S, FUN = FUN, ...), silent = TRUE))
16: FUN(X[[i]], ...)
17: lapply(seq_len(cores), inner.do)
18: mclapply(1:vsamp, function(samp) sampling(network, pixels, min.r,
 max.r, min.c, max.c, vrnd), mc.cores = no.cores)
An irrecoverable exception occurred. R is aborting now ...

Any ideas why this would arise? My code will run just fine for a number of
iterations, it is just that a few iterations will fail because of these
errors. I have tried to develop a simplified implementation of the
algorithm and that code is available here
<https://www.heath-henderson.com/research.html>. (See the code for "The
structure of risk-sharing networks" under Works in Progress. The data is
provided in that same directory.) The key function for the procedure is
called "sampling" and I have pasted it here in case somebody can spot
obvious issues:

sampling <- function(network, pixels, min.r, max.r, min.c, max.c, stop){
  pixel.count <- nrow(pixels)
  pixels <- pixels[sample(1:pixel.count),] # Randomize pixel order
  pixels <- as.list(pixels)    # Pixels to list
  results <- vector("list", pixel.count) # List to store results
  ntw1 <- network
  r1 <- assortativity_degree(ntw1) # Calculate initial assortativity coeff.
  c1 <- transitivity(ntw1, type="global", isolates="zero") # Calculate
initial clustering coeff.
  for (octr in 1:pixel.count){  # Run for each pixel
    lb.r <- pixels[[1]][octr]  # Unpack lower and upper bounds for pixel
    ub.r <- pixels[[2]][octr]
    lb.c <- pixels[[3]][octr]
    ub.c <- pixels[[4]][octr]
    center.r <- (lb.r + ub.r)/2  # Calculate pixel center
    center.c <- (lb.c + ub.c)/2
    rd1 <- ((r1 - center.r)/(max.r - min.r))^2 # Calculate components of
distance formula
    cd1 <- ((c1 - center.c)/(max.c - min.c))^2
    d1 <- sqrt(rd1 + cd1)   # Calculate initital distance
    cond1 <- (r1 < lb.r) || (r1 >= ub.r)
    cond2 <- (c1 < lb.c) || (c1 >= ub.c)
    ictr <- 1   # Initialize inner counter
    while ((cond1 || cond2) && ictr <= 1e+05){  # While outside pixel ...
      ntw2 <- rewire(ntw1, with=keeping_degseq(loops=FALSE, niter=1)) # One
trial
      r2 <- assortativity_degree(ntw2) # Calculate new assortativity coeff.
      c2 <- transitivity(ntw2, type="global", isolates="zero") # Calculate
new clustering coeff.
      rd2 <- ((r2 - center.r)/(max.r - min.r))^2
      cd2 <- ((c2 - center.c)/(max.c - min.c))^2
      d2 <- sqrt(rd2 + cd2)   # Calculate new distance
      if (d2 < d1) {  # If moving in the right direction ...
        ntw1 <- ntw2  # ... update values
        r1 <- r2
        c1 <- c2
        d1 <- d2
        cond1 <- (r1 < lb.r) || (r1 >= ub.r) # Check if still outside pixel
        cond2 <- (c1 < lb.c) || (c1 >= ub.c)
      }
      ictr <- ictr + 1
    }
    if (ictr <= 1e+05){   # If exit was successful ...
      ntw3 <- walk(ntw1, lb.r, ub.r, lb.c, ub.c, stop) # Execute walk
      dist <- mean_distance(ntw3)  # Calculate stats
      component <- max(components(ntw3)$csize)
      random.50 <- f.random(ntw3, 0.50, 1)
      targeted.50 <- f.targeted(ntw3, 0.50)
      targeted.75 <- f.targeted(ntw3, 0.75)
      results[[octr]] <- list(dist, component, random.50, targeted.50,
targeted.75)
    } else {results[[octr]] <- rep(list(NA), 5)}
  }
}

The inputs for the function include the network, a data table with the
assortativity-clustering coordinates to visit ("pixels"), the overall
maximum and minimum values of the assortativity-clustering space, and a
stopping criterion. Any help would be much appreciated, please let me know
if any additional information is necessary. Thanks!

Heath




-- 
*Heath Henderson, PhD*
Assistant Professor of Economics
Drake University
College of Business and Public Administration
359 Aliber Hall, Des Moines, IA 50311
515.271.2898 (Office)
612.867.4776 (Cell)
heath-henderson.com
_______________________________________________
igraph-help mailing list
igraph-help@nongnu.org
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to