igraph-help
[Top][All Lists]
Advanced

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

[igraph] as.undirected strips edge weights?


From: address@hidden
Subject: [igraph] as.undirected strips edge weights?
Date: Tue, 20 Oct 2009 23:32:27 -0700 (PDT)
User-agent: G2/1.0

Dear igraph-help,

I am attempting to compute eigenvector centrality on a weighted graph.
The evcent function provides a warning concerning "Weighted directed
graph in eigenvector centrality." Assuming that the centrality
function is not equipped to handle directed graphs, I have been
working to provide it with an undirected graph with weights. My code
now is as follows:

centralnode <- function(csvfile)
  { # read weighted graph
    m <- as.matrix(read.csv(csvfile, header=F))
    g <- graph.adjacency(m, weighted=TRUE)
    g <- as.undirected(g) # this line strips the E(g)$weight
information?
    wv <- normalize(E(g)$weight)
    return(which.max(evcent(g, weights=wv)$vector))
  }

What I am struggling with is the line as.undirected(g)...it removes
the edge weight information. Is there some sort of work-around? I
tried "as.undirected2" which I found in the igraph source, but it
appears that e(g)$weight is not a vertex attribute.

Thanks in advance,

-carson-




reply via email to

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