[BioC] graph/graphNEL: edge properties from edge name
Gustavo Lacerda
gusb at optimizelife.com
Wed May 19 01:51:56 CEST 2010
hi,
I would like to easily query the weight (or label) of an edge given its name.
e.g. suppose I have a graph 'g' whose nodes are labeled A1, A2, ...
I want to do something like: getEdge(g, "A1~A3")$weight
Any suggestions?
The best I can do at the moment is the code below, but I don't find it
very elegant that I need to do [[1]], and I don't like to reinvent the
wheel. Is there a standard function I can use?
Gustavo
parseTilde <- function(s) unlist(strsplit(s,"~"))
getEdgeWeight <- function(g, edgeName){
nodePair <- parseTilde(edgeName)
edgeData(g, from=nodePair[1], to=nodePair[2])[[1]]$weight
}
More information about the Bioconductor
mailing list