How to understand the contribution of edge-attributes value when multiple edges exist between two nodes?

Hi, Thanks for your work and support through this package.

I have a question about understanding the multiple edges and edge attributes.

In my Igraph object, I have multiple edges between some of the nodes.

is_simple(net_full)
# [1] TRUE

I have identified those instances using which_multiple(net_full). Now, I would like to understand how the edge.attribute values are coming from these edges individually.

edge_attr(net_full, "score")[c(1898, 5892, 6556, 6746, 7443, 8267, 8564)]
# [1] 161 189 310 433 917 216 324

count_multiple(net_full)[c(1898, 5892, 6556, 6746, 7443, 8267, 8564)]
# [1] 2 2 2 2 2 2 2

How can I find the contribution of the 161 from these 2 edges or edge types for the edge index 1898 individually?

count_multiple(net_full, 1898)
# [1] 2

This post is to continue the discussion from the Github repo, here.

Can you clarify the question please, perhaps with a self-contained minimal example?

These values do come from individual edges. None of these values are the combination of the “score” attribute of several parallel edges.

Each edge has a unique index. If there are two edges between the same pair of vertices, those two edges will have different indices. 1898 refers to a single edge, not a combination of two parallel edges.

This may not be the efficient way of doing this. Here is what I did (but, suggestions are welcome!)


The first few indices from the command c(1:11759454)[which_multiple(net_full)] result are c(1898, 5892, 6556, 6746, 7443, 8267, 8564), where the graph net_full contain 11759454 edges.

As I mentioned above, I looked into these indices. The command edge_attr(net_full, "score")[1898] resulted in 161. When I looked into count_multiple(net_full)[1898], it resulted in 2. I want to know how to find these 2.

When I looked into the get.edge.ids(net_full, c("N233", "N412")), it resulted only one edge id. Is it something as expected? If I understand clearly, your reply, there should be 2 edge ids, right?

Please see the discussion here:

get.edge.ids returns as many edge IDs as the size of the input. To get the IDs of both edges between these two vertices, you can use

get.edge.ids(net_full, c("N233", "N412",  "N233", "N412"))

Another important point is that which_multiple does not return TRUE for the first edge between any pair of vertices, only for the 2nd, 3rd, etc.

1 Like

Can you explain in more detail why you want to get all edge IDs for groups of parallel edges? I can imagine several possibilities, but I would like to know your actual motivation. Having some real-world use cases helps us decide on the best interface.

@szhorvat It is merely for understanding purposes; how edge.attribute values are grouped from each of the edges between a pair of nodes.


Edit: I will get back to you on this with more details.

Yes, of course that makes sense, and we are discussing how to make improvements for future versions. I asked because the perspective of users is very valuable when making decisions about such issues.

1 Like