# Specify igraph\_vs\_t from an array of integers?

**URL:** <https://igraph.discourse.group/t/specify-igraph-vs-t-from-an-array-of-integers/1146>\
**Category:** Usage\
**Tags:** C\
**Created:** [16 March 2022 05:23 UTC](https://igraph.discourse.group/t/specify-igraph-vs-t-from-an-array-of-integers/1146 "2022-03-16T05:23:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![crcox](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/crcox/32/721_2.png) [@crcox](https://igraph.discourse.group/u/crcox)\
**Post date:** [16 March 2022 05:23 UTC](https://igraph.discourse.group/t/specify-igraph-vs-t-from-an-array-of-integers/1146/1 "2022-03-16T05:23:46Z")

</div>

I am attempting to induce a subgraph based on a specific set of vertices. I have their vertex IDs as a 1-dimensional array of integers (for exampls `int x[2] = {1, 4};`), but `igraph_induce_subgraph` requires `igraph_vs_t`.

What is the simplest way to obtain the subgraph based on my array of integers ?

---

<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:** [16 March 2022 10:24 UTC](https://igraph.discourse.group/t/specify-igraph-vs-t-from-an-array-of-integers/1146/2 "2022-03-16T10:24:54Z")

</div>

Copy your array into an `igraph_vector_t` then use `igraph_vs_vector()`

[https://igraph.org/c/html/latest/igraph-Iterators.html#igraph\_vs\_vector](https://igraph.org/c/html/latest/igraph-Iterators.html#igraph_vs_vector)

---

<div class="post-metadata">

**Author:** ![crcox](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/crcox/32/721_2.png) [@crcox](https://igraph.discourse.group/u/crcox)\
**Post date:** [16 March 2022 11:35 UTC](https://igraph.discourse.group/t/specify-igraph-vs-t-from-an-array-of-integers/1146/3 "2022-03-16T11:35:46Z")

</div>

Thank you. Is there a way to tell igraph\_vector\_t that it will be holding integers and not floats? I was getting warnings while trying to create the vector from integers.

---

<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:** [16 March 2022 12:03 UTC](https://igraph.discourse.group/t/specify-igraph-vs-t-from-an-array-of-integers/1146/4 "2022-03-16T12:03:05Z")

</div>

You can ignore these warnings safely.

`igraph_vector_t` holds values of type `igraph_real_t`, which is currently `double`. In igraph 0.9 and earlier, most values used for indexing, such as vertex IDs, are stored as `igraph_real_t`. This is because igraph was originally written to be an R package, and R uses `double`s for everything, including integer values.

There is also `igraph_vector_int_t`, which holds `igraph_integer_t`. Currently, `igraph_integer_t` is `int`.

Starting with igraph 0.10, all values used for indexing, such as edge and vertex IDs, will be consistently `igraph_integer_t`. This means that `igraph_vs_vector()` will also take an `igraph_vector_int_t` argument, not an `igraph_vector_t` one. Additionally, `igraph_integer_t` will be a 64-bit type on 64-bit systems by default. You can find these changes on the [`develop` branch of the igraph repository](https://github.com/igraph/igraph/tree/develop). If you decide to use this development version, keep in mind that a large number of breaking changes have been made compared to 0.9, and you will need to adapt your existing code. These are mostly updating the types of IDs to be integers, but there are also some renamings and other interface changes. See the [changelog](https://github.com/igraph/igraph/blob/develop/CHANGELOG.md). You are very welcome to use the development version and give feedback, but be prepared for the rug to be pulled from under you from time to time: breaking changes are made regularly. That said, the development version should be more stable and less buggy than 0.9.

Why are we making so many breaking changes? From 1.0 onwards, the igraph API should be stable. We are cleaning up the API and making it more consistent for that release. Most, but not all breaking changes will be made in 0.10, with a 0.11 almost certain to follow before 1.0.

---

<div class="post-metadata">

**Author:** ![crcox](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/crcox/32/721_2.png) [@crcox](https://igraph.discourse.group/u/crcox)\
**Post date:** [16 March 2022 12:08 UTC](https://igraph.discourse.group/t/specify-igraph-vs-t-from-an-array-of-integers/1146/5 "2022-03-16T12:08:48Z")

</div>

Thank you so much for the answer and broader context! Your work on `igraph` is greatly appreciated.
