Question

I want to construct a new centrality measure using igraph, preferably in R.

How would I begin this?

For example, would I be better adding to the igraph C library or the R interface?

Was it helpful?

Solution

This really boils down to what your comfortable level. That said, igraph is a primarily a C library (you can browse all the source code on sourceforge), so the most logical way to extend it is probably in C. For instance, the closeness function in R just call the related C function:

> closeness
function (graph, v = V(graph), mode = c("all", "out", "in")) 
{
    if (!is.igraph(graph)) {
        stop("Not a graph object")
    }
    mode <- igraph.match.arg(mode)
    mode <- switch(mode, out = 1, `in` = 2, all = 3)
    on.exit(.Call("R_igraph_finalizer", PACKAGE = "igraph"))
    .Call("R_igraph_closeness", graph, as.igraph.vs(v), as.numeric(mode), 
        PACKAGE = "igraph")
}

Here is the existing centrality sourcecode.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top