I'm finding that any call to get/set vertex attribute using the igraph library within callback causes a segfault in R. For example, the trivial callback from a segment of code:
dfsCallBack <- function(graph, data, extra) {
cat("in:", paste(collapse=", ", data), "\n")
distFromRoot <- data[2]
vertexID <- data[1]
set.vertex.attribute(graph, 0, name = 'color', value = 'blue')
FALSE
}
graph.dfs(g, 1, in.callback = dfsCallBack)
Produces this error:
graph.dfs(g, 1, in.callback = dfsCallBack)
in: 0, 0
*** caught segfault ***
address 0x0, cause 'memory not mapped'
Traceback:
1: .Call("R_igraph_dfs", graph, root, neimode, unreachable, as.logical(order), as.logical(order.out), as.logical(father), as.logical(dist), in.callback, out.callback, extra, rho, PACKAGE = "igraph")
2: graph.dfs(g, 1, in.callback = dfsCallBack)
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:
What's wrong here? Also, igraph should probably be more robust in dealing with these errors, crashing out of R is not ideal for a high-level language like R.