[R] help finding edge connecting two nodes
ruipbarradas at sapo.pt
Fri Oct 19 14:02:20 CEST 2012
You should give a reproducible example showing us what you have tried,
with an example dataset.
Try the following.
# A graph I've just drawn
v <- c(1,2,1,3,1,4,2,5,2,4,3,5,3,6,5,7,5,8,5,10,6,8,6,10,7,8,7,9,8,9)
g <- graph(v, directed = FALSE)
E(g)$weight <- 1:15
# This is what you want
E(g)[5 %--% 10]$weight
See the help for
Hope this helps,
Em 18-10-2012 23:05, dhaval at mit.edu escreveu:
> I'm new to R and igraph and I was wondering if anybody can help me with the
> I want to find the edge weight between two vertices in a graph. My graph
> structure is defined by the normal ego (node1), alter (node2) and the weight
> of the edge between them.
> I know that I can get the weight for each of the edges in the list of edges
> that originate from node number 5 using E(igraph_friendship) [ from(5)
> ]$weight And that I can find the weight for each of the edges in the list of
> edges that end onto node number 10 using E(igraph_friendship) [ to(10)
> But what if I simply want to find the weight of the edge that simple
> connects just node 5 and node 10?
> Alternatively, if I can get the identifier of the edge that connects node 5
> and 10 in the list of all edges, E(igraph_friendship), that would work too.
> Thanks a lot for your help, I've been looking around a lot for it and I
> really appreciate your help!
> View this message in context: http://r.789695.n4.nabble.com/help-finding-edge-connecting-two-nodes-tp4646688.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help