igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[igraph] as.undirected() strips vertex attributes?


From: uxzmdlj02
Subject: [igraph] as.undirected() strips vertex attributes?
Date: Fri, 21 Sep 2007 14:08:48 -0500

It looks like as.undirected() strips vertex attributes in igraph 0.4.3. Is this a bug?

Example:

> list.vertex.attributes(g)
[1] "id"
> list.vertex.attributes(as.undirected(g))
character(0)

Any easy workaround?
For now I'll just use:

as.undirected2 <- function(g){
    ## store the attributes:
    tempAtt <- list()
    for(a in list.vertex.attributes(g)){
        tempAtt <- c(tempAtt,list(get.vertex.attribute(g,a)))
        names(tempAtt)[length(tempAtt)] <- a
    }

    ## convert the graph:
    res <- as.undirected(g)

    ## restore the attributes:
    for(a in names(tempAtt)){
        set.vertex.attribute(g,a,value=tempAtt[[a]])
    }
}

Will this work? Is this actually a bug?

Thanks,
Peter




reply via email to

[Prev in Thread] Current Thread [Next in Thread]