The program below is an attempt to create a “quotient graph”. The equivalence relation is being strongly connected. When we purposely create an error in the name parameter of the vertex.attr.comb function (set x to xx) then R gives an error and after a few seconds crashes.
When we make a similar error in the name parameter of the edge.attr.comb
function (set x to xx) then R exhibits the same behaviour.
Both contract and simplify are straightforward wrappers into C. So my question is: is this an R-interface or a C igraph library problem?
# https://github.com/igraph/rigraph/issues/398
# create quotient graph, g/~, where ~ equivalence relation "strongly connected"
library(igraph)
g <- graph_from_literal( 1-+2, 2-+3, 3-+1, 1-+4, 2-+4, 2-+5, 3-+5, 3-+6, 1-+6)
edge_attr(g) <- list(name = letters[seq_len(ecount(g))]
, weight = rep(1, ecount(g) )
)
# g <- delete_vertex_attr(g, name="name") # no crash, when commented out
plot(g)
SCC <- clusters(g, mode=c("strong"))
vg <- contract(g
, SCC$membership
, vertex.attr.comb=list( category="first"
, name=function(x) paste(x[seq_len(length(x))], collapse="=")
)
) # crash when name=function(z)
dev.new(); plot(vg, edge.label = paste(E(vg)$name, E(vg)$weight, sep=","))
qg <- simplify( vg
, remove.loops=FALSE
, edge.attr.comb=list( category="first"
, name=function(x) paste(x[seq_len(length(x))], collapse="/")
, weight="sum"
)
)
dev.new(); plot(qg, edge.label = E(qg)$weight)