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

**URL:** <https://igraph.discourse.group/t/how-to-understand-the-contribution-of-edge-attributes-value-when-multiple-edges-exist-between-two-nodes/893>\
**Category:** Usage\
**Tags:** R\
**Created:** [11 October 2021 11:13 UTC](https://igraph.discourse.group/t/how-to-understand-the-contribution-of-edge-attributes-value-when-multiple-edges-exist-between-two-nodes/893 "2021-10-11T11:13:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![peranti](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/peranti/32/594_2.png) [@peranti](https://igraph.discourse.group/u/peranti)\
**Post date:** [11 October 2021 11:13 UTC](https://igraph.discourse.group/t/how-to-understand-the-contribution-of-edge-attributes-value-when-multiple-edges-exist-between-two-nodes/893/1 "2021-10-11T11:13:40Z")

</div>

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.

```auto
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.

```auto
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?

```auto
count_multiple(net_full, 1898)
# [1] 2

```

* * *

This post is to continue the discussion from the Github repo, [here](https://github.com/igraph/rigraph/issues/483).

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [11 October 2021 12:29 UTC](https://igraph.discourse.group/t/how-to-understand-the-contribution-of-edge-attributes-value-when-multiple-edges-exist-between-two-nodes/893/2 "2021-10-11T12:29:16Z")

</div>

> [@peranti](#):
>
> Now, I would like to understand how the edge.attribute values are coming from these edges individually.
> 
> ```auto
> edge_attr(net_full, "score")[c(1898, 5892, 6556, 6746, 7443, 8267, 8564)]
> # [1] 161 189 310 433 917 216 324
> 
> ```

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.

> [@peranti](#):
>
> How can I find the contribution of the `161` from these `2` edges or edge types for the edge index `1898` individually?

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.

---

<div class="post-metadata">

**Author:** ![peranti](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/peranti/32/594_2.png) [@peranti](https://igraph.discourse.group/u/peranti)\
**Post date:** [11 October 2021 12:49 UTC](https://igraph.discourse.group/t/how-to-understand-the-contribution-of-edge-attributes-value-when-multiple-edges-exist-between-two-nodes/893/3 "2021-10-11T12:49:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [11 October 2021 12:54 UTC](https://igraph.discourse.group/t/how-to-understand-the-contribution-of-edge-attributes-value-when-multiple-edges-exist-between-two-nodes/893/4 "2021-10-11T12:54:22Z")

</div>

Please see the discussion here:

> <https://github.com/igraph/rigraph/issues/484>
>
> I would expect the following to return \`1, 2, 3\` instead of \`3\`:
> 
> \`\`\`
> \> g \<- …make\_graph(c(1,2, 1,2, 1,2))
> \> get.edge.ids(g, c(1,2), multi=T)
> \[1\] 3
> \`\`\`
> 
> I am using the current \`dev\` branch.
> 
> The relevant function should be:
> 
> https://github.com/igraph/rigraph/blob/dev/tools/stimulus/rinterface.c.in#L8363
> 
> which dispatches to \`igraph\_get\_eids\_multi()\` as it should. What am I misunderstanding here, and why does it not work?
> 
> Not being familiar enough with R/igraph internals yet, it is unclear to me what \`C\_R\_igraph\_get\_eids\` is. Does it map to \`igraph\_get\_eids\` through stimulus (which would explain the behaviour) or to \`R\_igraph\_get\_eids\` (which is what should happen)?

`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.

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [11 October 2021 12:57 UTC](https://igraph.discourse.group/t/how-to-understand-the-contribution-of-edge-attributes-value-when-multiple-edges-exist-between-two-nodes/893/5 "2021-10-11T12:57:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![peranti](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/peranti/32/594_2.png) [@peranti](https://igraph.discourse.group/u/peranti)\
**Post date:** [8 November 2021 10:56 UTC](https://igraph.discourse.group/t/how-to-understand-the-contribution-of-edge-attributes-value-when-multiple-edges-exist-between-two-nodes/893/6 "2021-11-08T10:56:11Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [8 November 2021 11:07 UTC](https://igraph.discourse.group/t/how-to-understand-the-contribution-of-edge-attributes-value-when-multiple-edges-exist-between-two-nodes/893/7 "2021-11-08T11:07:16Z")

</div>

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.
