Try this:

E(g)[which(V(g)$color == "red") %--% which(V(g)$color == "red")]

This seems to work for me - just tried it in R.
T.


On Fri, Oct 14, 2016 at 11:37 PM, Luca Rossi <l...@itu.dk> wrote:
> Thank you Tamas!
>
> I've tried what you suggested (it looks exactly what I was looking for) but 
> for some reason it gives me an error:
> Error: unexpected '==' in "E(g)[V(g)$color == "red" %--% V(g)$color =="
>
> I really don't understand what's wrong...
>
> l.
>
>
> ________________________________________
> From: igraph-help <igraph-help-bounces+lucr=itu...@nongnu.org> on behalf of 
> Tamas Nepusz <nta...@rmki.kfki.hu>
> Sent: 11 October 2016 17:09
> To: Help for igraph users
> Subject: Re: [igraph] listing edges connecting nodes with same attributes
>
> Hello,
>
> Use the "%--%" operator when indexing the edge sequence; see this page
> for more details (under the heading "Special functions"):
>
> http://igraph.org/r/doc/igraph-es-indexing.html
>
> Example:
>
> g <- grg.game(100, 0.2)
> V(g)$color <- c("red", "green")
> E(g)[V(g)$color == "red" %--% V(g)$color == "red"]
>
> This will give you all the edges between red nodes; you can then use
> length() to figure out how many such edges there are.
>
> T.
>
>
> On Tue, Oct 11, 2016 at 11:52 AM, Luca Rossi <l...@itu.dk> wrote:
>> Hello,
>>
>> I’m sure this is a very simple question but for some reason I can’t figure 
>> out how to do it.
>> I need to list all the edges connecting nodes with a specific attribute. 
>> (e.g. nodes can be “red” or “green”). So i want to now how many dyads 
>> red-red, red-green, green-green.
>> I’ve tried with edge_connectivity but it doesn’t work when source and target 
>> are the same node (as it happens in this case:
>>
>>  edge_connectivity(g,source = V(g)[V(g)$color == "green"],target = 
>> V(g)[V(g)$color=="green”])
>>
>>
>> is there any way to do this?
>>
>> Thank you !
>>
>> Luca
>>
>>
>> _______________________________________________
>> igraph-help mailing list
>> igraph-help@nongnu.org
>> https://lists.nongnu.org/mailman/listinfo/igraph-help
>
> _______________________________________________
> igraph-help mailing list
> igraph-help@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/igraph-help
> _______________________________________________
> igraph-help mailing list
> igraph-help@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/igraph-help

_______________________________________________
igraph-help mailing list
igraph-help@nongnu.org
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to