# Bool edge selector

**URL:** <https://igraph.discourse.group/t/bool-edge-selector/55>\
**Category:** Usage\
**Tags:** C\
**Created:** [30 January 2020 12:13 UTC](https://igraph.discourse.group/t/bool-edge-selector/55 "2020-01-30T12:13:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![carissableker](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/carissableker/32/98_2.png) [@carissableker](https://igraph.discourse.group/u/carissableker)\
**Post date:** [30 January 2020 12:13 UTC](https://igraph.discourse.group/t/bool-edge-selector/55/1 "2020-01-30T12:13:17Z")

</div>

Is it possible to select edges from a vector of `1`'s and `0`'s?

For example I have a graph G (with `igraph_ecount = E`) and a vector of length `E` with `1`s for the edge IDs I want in the edge selector (`igraph_es_vector`) and `0`s for the rest (to leave out). I can make a loop to collect the IDs, but I was wondering if there is another option.

---

<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:** [30 January 2020 14:50 UTC](https://igraph.discourse.group/t/bool-edge-selector/55/2 "2020-01-30T14:50:35Z")

</div>

I am not terribly experienced with edge selectors, but I do not think that there is any built-in functionality for this. I would write a function to find the positions of the `1`s in the bool vector, store the positions in a vector, then use `igraph_es_vector` on that.

---

<div class="post-metadata">

**Author:** ![vtraag](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/vtraag/32/38_2.png) [@vtraag](https://igraph.discourse.group/u/vtraag)\
**Post date:** [30 January 2020 16:30 UTC](https://igraph.discourse.group/t/bool-edge-selector/55/3 "2020-01-30T16:30:57Z")

</div>

I believe you are right @szhorvat, there doesn’t seem to be such a function.

It might be useful to have a functionality `igraph_vector_which_equals` similar to the [`igraph_vector_which_max`](https://igraph.org/c/doc/igraph-Data-structures.html#igraph_vector_which_max) function which returns a vector of elements that equals the indicated value. That way, it would be a bit easier to get the required vector.
