igraph-help
[Top][All Lists]
Advanced

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

[igraph] accessing edge attributes via vertex indices?


From: David Robinson
Subject: [igraph] accessing edge attributes via vertex indices?
Date: Thu, 9 Jan 2014 06:35:54 -0800 (PST)

This is related to my previous question about combining vertex attributes (thanks Tamas for the insight in figuring that out), but relates to operations on edges.

I have an undirected graph gA, with no loops and no multiple edges. Each edge of the graph has a vector of attributes, e.g. E(gA)$weight . I would like to be able to find the attributes of the edge that connects two specific vertices. Something similar would happen in the following very simplified R code snippet: 

sum<-0
for (i in 1:vcount(gA) {
   for (j in 1: vcount(gA) {
      sum <- sum+ E(gA)[from(i) & to(j)]$weight
    }
}

A couple of issues arise: Ideally, I would like to only do this when an edge exists between i and j exist, but I cannot seem to find a logic statement that returns either TRUE/FALSE.  The second issue occurs when i=j where the result of E(gA)[from(i) & to(j)] is multiple values. 

I think that the problem boils down to the question: given two vertices, can I determine if an edge exists between them and, if so, what is the index of the edge between them? 

Thanks again for all the help, 
David


reply via email to

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