# Permutations

**URL:** <https://igraph.discourse.group/t/permutations/1654>\
**Category:** Usage\
**Tags:** R\
**Created:** [1 September 2023 16:57 UTC](https://igraph.discourse.group/t/permutations/1654 "2023-09-01T16:57:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![francesco\_doppio](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/francesco_doppio/32/990_2.png) [@francesco\_doppio](https://igraph.discourse.group/u/francesco_doppio)\
**Post date:** [1 September 2023 16:57 UTC](https://igraph.discourse.group/t/permutations/1654/1 "2023-09-01T16:57:57Z")

</div>

Dear Gabor, I would like your library to calculate all possible enumerations of permutations of the vertices of a graph. For each generated permutation I need to write the arc data set (2 columns: $From and $To). My graph has 7 nodes of which 3 are source nodes, it’s a directed graph. Unfortunately my knowledge of both resources (R, igraph) is not enough to compose the right R code. May I kindly ask for your help?

---

<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:** [1 September 2023 17:01 UTC](https://igraph.discourse.group/t/permutations/1654/2 "2023-09-01T17:01:16Z")

</div>

There are other packages that can generate permutations, for example

```auto
> library(combinat)
> permn(1:3)
[[1]]
[1] 1 2 3

[[2]]
[1] 1 3 2

[[3]]
[1] 3 1 2

[[4]]
[1] 3 2 1

[[5]]
[1] 2 3 1

[[6]]
[1] 2 1 3

```

Once you have a permutation, you can apply it to a graph using `igraph::permute()`.
