# Finding minimal separators between pairs of non adjacent vertices

**URL:** <https://igraph.discourse.group/t/finding-minimal-separators-between-pairs-of-non-adjacent-vertices/151>\
**Category:** Usage\
**Tags:** Python\
**Created:** [24 March 2020 10:21 UTC](https://igraph.discourse.group/t/finding-minimal-separators-between-pairs-of-non-adjacent-vertices/151 "2020-03-24T10:21:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichelangeloConserva](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/michelangeloconserva/32/176_2.png) [@MichelangeloConserva](https://igraph.discourse.group/u/MichelangeloConserva)\
**Post date:** [24 March 2020 10:21 UTC](https://igraph.discourse.group/t/finding-minimal-separators-between-pairs-of-non-adjacent-vertices/151/1 "2020-03-24T10:21:50Z")

</div>

Hello,  
I am trying to find all the minimal separators between pairs of non adjacent vertices.

For now I created a basic graph following the tutorial but I am stuck.

There is a function as explained in [https://igraph.org/c/doc/igraph-Iterators.html#igraph\_vs\_nonadj](https://igraph.org/c/doc/igraph-Iterators.html#igraph_vs_nonadj) to find the non adjacent vertices of a given vertex but it seems that this option is only available in C and I would like to use Python.  
What I would like to have is a list of pairs of non adjacent vertices.

Same for the minimal separators function as in [https://igraph.org/c/doc/igraph-Separators.html#igraph\_is\_minimal\_separator](https://igraph.org/c/doc/igraph-Separators.html#igraph_is_minimal_separator).

This is the code I wrote until now.

```
from igraph import *
g = Graph([(0,1), (0,2), (2,3), (3,4), (4,2), (2,5), (5,0), (6,3), (5,6)])
layout = g.layout("kk")
g.vs["label"] = g.vs.indices
plot(g, layout = layout, bbox = (300, 300), margin = 40)

```

Could you please provide guidance on how to use these functions in Python?

Thank you very much.

Michelangelo

---

<div class="post-metadata">

**Author:** ![tamas](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/tamas/32/1261_2.png) [@tamas](https://igraph.discourse.group/u/tamas)\
**Post date:** [26 March 2020 17:34 UTC](https://igraph.discourse.group/t/finding-minimal-separators-between-pairs-of-non-adjacent-vertices/151/2 "2020-03-26T17:34:32Z")

</div>

> [@MichelangeloConserva](#):
>
> What I would like to have is a list of pairs of non adjacent vertices.

If your graph is relatively small, then you can achieve this with some basic Python coding. Assuming that your graph is undirected:

```python
from itertools import combinations

nonadjacent_pairs = sorted(set(combinations(range(graph.vcount()), 2)) - set(graph.get_edgelist()))

```

The minimal separators function is a [method on the Graph object](https://igraph.org/python/doc/igraph.GraphBase-class.html#is_minimal_separator).
