Hi,

Thank you for your help! I will try to think of how to provide examples
next time!

Your way works best! Another way I found from stackoverflow (see the post
at
http://stackoverflow.com/questions/12964332/igraph-edge-between-two-vertices/12980550#12980550)
was
to convert the graph into an adjacency matrix and then use simple matrix
indices .

As explained in the post, it took me a while to figure out how to get my
edge lists with weights into an adjacency matrix. I tried to do it the
usual way using graph.data.frame but then would get a weird error when I
tried translating the igraph object to and adjacency matrix (error: Error
in .M.kind(x) : not yet implemented for matrix w/ typeof character). This
post helped do the trick:
https://sites.google.com/site/daishizuka/toolkits/sna/weighted-edgelists.

Best,

Dhaval

On Fri, Oct 19, 2012 at 8:02 AM, Rui Barradas <ruipbarradas@sapo.pt> wrote:

> Hello,
>
> 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)
> plot(g, layout=layout.fruchterman.**reingold)
> E(g)$weight <- 1:15
>
> # This is what you want
> E(g)[5 %--% 10]$weight
>
>
> See the help for
>
> ?igraph::iterators
>
>
> Hope this helps,
>
> Rui Barradas
> Em 18-10-2012 23:05, dhaval@mit.edu escreveu:
>
>> I'm new to R and igraph and I was wondering if anybody can help me with
>> the
>> following.
>>
>> 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)
>> ]$weight
>>
>> 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<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@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>




On Fri, Oct 19, 2012 at 8:02 AM, Rui Barradas <ruipbarradas@sapo.pt> wrote:

> Hello,
>
> 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)
> plot(g, layout=layout.fruchterman.**reingold)
> E(g)$weight <- 1:15
>
> # This is what you want
> E(g)[5 %--% 10]$weight
>
>
> See the help for
>
> ?igraph::iterators
>
>
> Hope this helps,
>
> Rui Barradas
> Em 18-10-2012 23:05, dhaval@mit.edu escreveu:
>
>> I'm new to R and igraph and I was wondering if anybody can help me with
>> the
>> following.
>>
>> 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)
>> ]$weight
>>
>> 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<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@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

	[[alternative HTML version deleted]]


