Files
Abdelrahman Said a11edf0c53 Add graph references
2026-06-28 13:49:01 +01:00

777 lines
42 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chapter 24. Vertex separators</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="igraph Reference Manual">
<link rel="up" href="index.html" title="igraph Reference Manual">
<link rel="prev" href="igraph-Flows.html" title="Chapter 23. Maximum flows, minimum cuts and related measures">
<link rel="next" href="igraph-Community.html" title="Chapter 25. Detecting community structure">
<script type="text/javascript" src="toggle.js"></script><link rel="stylesheet" href="style.css" type="text/css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css">
<link rel="chapter" href="igraph-Introduction.html" title="Chapter 1. Introduction">
<link rel="chapter" href="igraph-Installation.html" title="Chapter 2. Installation">
<link rel="chapter" href="igraph-Tutorial.html" title="Chapter 3. Tutorial">
<link rel="chapter" href="igraph-Basic.html" title="Chapter 4. Basic data types and interface">
<link rel="chapter" href="igraph-Error.html" title="Chapter 5. Error handling">
<link rel="chapter" href="igraph-Memory.html" title="Chapter 6. Memory (de)allocation">
<link rel="chapter" href="igraph-Data-structures.html" title="Chapter 7. Data structure library: vector, matrix, other data types">
<link rel="chapter" href="igraph-Random.html" title="Chapter 8. Random numbers">
<link rel="chapter" href="igraph-Iterators.html" title="Chapter 9. Vertex and edge selectors and sequences, iterators">
<link rel="chapter" href="igraph-Attributes.html" title="Chapter 10. Graph, vertex and edge attributes">
<link rel="chapter" href="igraph-Generators.html" title="Chapter 11. Deterministic graph generators">
<link rel="chapter" href="igraph-Games.html" title='Chapter 12. Stochastic graph generators ("games")'>
<link rel="chapter" href="igraph-Bipartite.html" title="Chapter 13. Bipartite, i.e. two-mode graphs">
<link rel="chapter" href="igraph-Spatial.html" title="Chapter 14. Spatial graphs">
<link rel="chapter" href="igraph-Operators.html" title="Chapter 15. Graph operators">
<link rel="chapter" href="igraph-Visitors.html" title="Chapter 16. Graph visitors">
<link rel="chapter" href="igraph-Structural.html" title="Chapter 17. Structural properties of graphs">
<link rel="chapter" href="igraph-Cycles.html" title="Chapter 18. Graph cycles">
<link rel="chapter" href="igraph-Cliques.html" title="Chapter 19. Cliques and independent vertex sets">
<link rel="chapter" href="igraph-Motifs.html" title="Chapter 20. Graph motifs, dyad census and triad census">
<link rel="chapter" href="igraph-Isomorphism.html" title="Chapter 21. Graph isomorphism">
<link rel="chapter" href="igraph-Coloring.html" title="Chapter 22. Graph coloring">
<link rel="chapter" href="igraph-Flows.html" title="Chapter 23. Maximum flows, minimum cuts and related measures">
<link rel="chapter" href="igraph-Separators.html" title="Chapter 24. Vertex separators">
<link rel="chapter" href="igraph-Community.html" title="Chapter 25. Detecting community structure">
<link rel="chapter" href="igraph-Graphlets.html" title="Chapter 26. Graphlets">
<link rel="chapter" href="igraph-HRG.html" title="Chapter 27. Hierarchical random graphs">
<link rel="chapter" href="igraph-Embedding.html" title="Chapter 28. Embedding of graphs">
<link rel="chapter" href="igraph-Layout.html" title="Chapter 29. Generating layouts for graph drawing">
<link rel="chapter" href="igraph-Processes.html" title="Chapter 30. Processes on graphs">
<link rel="chapter" href="igraph-Foreign.html" title="Chapter 31. Reading and writing graphs from and to files">
<link rel="chapter" href="igraph-Linalg.html" title="Chapter 32. Using BLAS, LAPACK and ARPACK for igraph matrices and graphs">
<link rel="chapter" href="igraph-Nongraph.html" title="Chapter 33. Non-graph related functions">
<link rel="chapter" href="igraph-Advanced.html" title="Chapter 34. Advanced igraph programming">
<link rel="chapter" href="igraph-Glossary.html" title="Chapter 35. Glossary">
<link rel="chapter" href="igraph-Licenses.html" title="Chapter 36. Licenses for igraph and this manual">
<link rel="index" href="ix01.html" title="Index">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navigation-header mb-4" width="100%" summary="Navigation header"><div class="btn-group">
<a accesskey="p" class="btn btn-light" href="igraph-Flows.html"><i class="fa fa-chevron-left"></i>
Previous
</a><a accesskey="h" class="btn btn-light" href="index.html"><i class="fa fa-home"></i>
Home
</a><a accesskey="n" class="btn btn-light" href="igraph-Community.html"><i class="fa fa-chevron-right"></i>
Next
</a>
</div></div>
<div class="chapter">
<div class="titlepage"><div><div><h1 class="title">
<a name="igraph-Separators"></a>Chapter 24. Vertex separators</h1></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="igraph-Separators.html#igraph_is_separator">1. <code class="function">igraph_is_separator</code> — Would removing this set of vertices disconnect the graph?</a></span></dt>
<dt><span class="section"><a href="igraph-Separators.html#igraph_is_minimal_separator">2. <code class="function">igraph_is_minimal_separator</code> — Decides whether a set of vertices is a minimal separator.</a></span></dt>
<dt><span class="section"><a href="igraph-Separators.html#igraph_all_minimal_st_separators">3. <code class="function">igraph_all_minimal_st_separators</code> — List all vertex sets that are minimal (s,t) separators for some s and t.</a></span></dt>
<dt><span class="section"><a href="igraph-Separators.html#igraph_minimum_size_separators">4. <code class="function">igraph_minimum_size_separators</code> — Find all minimum size separating vertex sets.</a></span></dt>
<dt><span class="section"><a href="igraph-Separators.html#igraph_even_tarjan_reduction">5. <code class="function">igraph_even_tarjan_reduction</code> — Even-Tarjan reduction of a graph.</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="igraph_is_separator"></a>1. <code class="function">igraph_is_separator</code> — Would removing this set of vertices disconnect the graph?</h2></div></div></div>
<a class="indexterm" name="id-1.25.2.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_is_separator(const igraph_t *graph,
const igraph_vs_t candidate,
igraph_bool_t *res);
</pre></div>
<p>
</p>
<p>
A vertex set <code class="constant">S</code> is a separator if there are vertices <code class="constant">u</code> and <code class="constant">v</code>
in the graph such that all paths between <code class="constant">u</code> and <code class="constant">v</code> pass through
some vertices in <code class="constant">S</code>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph. It may be directed, but edge
directions are ignored.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>candidate</code></em>:</span></p></td>
<td><p>
The candidate separator.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>res</code></em>:</span></p></td>
<td><p>
Pointer to a boolean variable, the result is stored here.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(|V|+|E|), linear in the number vertices and edges.
</p>
<div class="hideshow" onClick="toggle(this, event)">
<div class="example">
<a name="id-1.25.2.8.1"></a><p class="title"><b>Example 24.1.  File <code class="code">examples/simple/igraph_is_separator.c</code></b></p>
<div class="example-contents">
<pre class="programlisting"><span class="strong"><strong>#include</strong></span> &lt;igraph.h&gt;
<span class="strong"><strong>#include</strong></span> &lt;stdio.h&gt;
<span class="strong"><strong>#define</strong></span> <span class="strong"><strong>FAIL</strong></span>(msg, error) <span class="strong"><strong>do</strong></span> { <span class="strong"><strong>printf</strong></span>(msg "\n") ; <span class="strong"><strong>return</strong></span> error; } <span class="strong"><strong>while</strong></span> (0)
int <span class="strong"><strong>main</strong></span>(void) {
igraph_t graph;
igraph_vector_int_t sep;
igraph_bool_t result;
<span class="emphasis"><em>/* Initialize the library. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_setup" title="4.1. igraph_setup — Initializes the igraph library.">igraph_setup</a></strong></span>();
<span class="emphasis"><em>/* Simple star graph, remove the center */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Generators.html#igraph_star" title="4.1. igraph_star — Creates a star graph, every vertex connects only to the center.">igraph_star</a></strong></span>(&amp;graph, 10, IGRAPH_STAR_UNDIRECTED, 0);
<span class="strong"><strong><a class="link" href="igraph-Separators.html#igraph_is_separator" title="1. igraph_is_separator — Would removing this set of vertices disconnect the graph?">igraph_is_separator</a></strong></span>(&amp;graph, <span class="strong"><strong><a class="link" href="igraph-Iterators.html#igraph_vss_1" title="4.3. igraph_vss_1 — Vertex set with a single vertex (immediate version).">igraph_vss_1</a></strong></span>(0), &amp;result);
<span class="strong"><strong>if</strong></span> (!result) {
<span class="strong"><strong>FAIL</strong></span>("Center of star graph failed.", 1);
}
<span class="emphasis"><em>/* Same graph, but another vertex */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Separators.html#igraph_is_separator" title="1. igraph_is_separator — Would removing this set of vertices disconnect the graph?">igraph_is_separator</a></strong></span>(&amp;graph, <span class="strong"><strong><a class="link" href="igraph-Iterators.html#igraph_vss_1" title="4.3. igraph_vss_1 — Vertex set with a single vertex (immediate version).">igraph_vss_1</a></strong></span>(6), &amp;result);
<span class="strong"><strong>if</strong></span> (result) {
<span class="strong"><strong>FAIL</strong></span>("Non-center of star graph failed.", 2);
}
<span class="emphasis"><em>/* Same graph, all vertices but the center */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Separators.html#igraph_is_separator" title="1. igraph_is_separator — Would removing this set of vertices disconnect the graph?">igraph_is_separator</a></strong></span>(&amp;graph, <span class="strong"><strong><a class="link" href="igraph-Iterators.html#igraph_vss_range" title="4.5. igraph_vss_range — An interval of vertices (immediate version).">igraph_vss_range</a></strong></span>(1, 10), &amp;result);
<span class="strong"><strong>if</strong></span> (result) {
<span class="strong"><strong>FAIL</strong></span>("All non-central vertices of star graph failed.", 5);
}
<span class="emphasis"><em>/* Same graph, all vertices */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Separators.html#igraph_is_separator" title="1. igraph_is_separator — Would removing this set of vertices disconnect the graph?">igraph_is_separator</a></strong></span>(&amp;graph, <span class="strong"><strong><a class="link" href="igraph-Iterators.html#igraph_vss_range" title="4.5. igraph_vss_range — An interval of vertices (immediate version).">igraph_vss_range</a></strong></span>(0, 10), &amp;result);
<span class="strong"><strong>if</strong></span> (result) {
<span class="strong"><strong>FAIL</strong></span>("All vertices of star graph failed.", 6);
}
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(&amp;graph);
<span class="emphasis"><em>/* Karate club */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Generators.html#igraph_famous" title="8.1. igraph_famous — Create a famous graph by simply providing its name.">igraph_famous</a></strong></span>(&amp;graph, "zachary");
<span class="strong"><strong>igraph_vector_int_init</strong></span>(&amp;sep, 0);
<span class="strong"><strong>igraph_vector_int_push_back</strong></span>(&amp;sep, 32);
<span class="strong"><strong>igraph_vector_int_push_back</strong></span>(&amp;sep, 33);
<span class="strong"><strong><a class="link" href="igraph-Separators.html#igraph_is_separator" title="1. igraph_is_separator — Would removing this set of vertices disconnect the graph?">igraph_is_separator</a></strong></span>(&amp;graph, <span class="strong"><strong><a class="link" href="igraph-Iterators.html#igraph_vss_vector" title="4.4. igraph_vss_vector — Vertex set based on a vector (immediate version).">igraph_vss_vector</a></strong></span>(&amp;sep), &amp;result);
<span class="strong"><strong>if</strong></span> (!result) {
<span class="strong"><strong>FAIL</strong></span>("Karate network (32,33) failed", 3);
}
<span class="strong"><strong>igraph_vector_int_resize</strong></span>(&amp;sep, 5);
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#VECTOR" title="2.4.1. VECTOR — Accessing an element of a vector.">VECTOR</a></strong></span>(sep)[0] = 8;
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#VECTOR" title="2.4.1. VECTOR — Accessing an element of a vector.">VECTOR</a></strong></span>(sep)[1] = 9;
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#VECTOR" title="2.4.1. VECTOR — Accessing an element of a vector.">VECTOR</a></strong></span>(sep)[2] = 19;
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#VECTOR" title="2.4.1. VECTOR — Accessing an element of a vector.">VECTOR</a></strong></span>(sep)[3] = 30;
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#VECTOR" title="2.4.1. VECTOR — Accessing an element of a vector.">VECTOR</a></strong></span>(sep)[4] = 31;
<span class="strong"><strong><a class="link" href="igraph-Separators.html#igraph_is_separator" title="1. igraph_is_separator — Would removing this set of vertices disconnect the graph?">igraph_is_separator</a></strong></span>(&amp;graph, <span class="strong"><strong><a class="link" href="igraph-Iterators.html#igraph_vss_vector" title="4.4. igraph_vss_vector — Vertex set based on a vector (immediate version).">igraph_vss_vector</a></strong></span>(&amp;sep), &amp;result);
<span class="strong"><strong>if</strong></span> (result) {
<span class="strong"><strong>FAIL</strong></span>("Karate network (8,9,19,30,31) failed", 4);
}
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(&amp;graph);
<span class="strong"><strong>igraph_vector_int_destroy</strong></span>(&amp;sep);
<span class="strong"><strong>return</strong></span> 0;
}
</pre>
<p></p>
</div>
</div>
<br class="example-break">
</div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="igraph_is_minimal_separator"></a>2. <code class="function">igraph_is_minimal_separator</code> — Decides whether a set of vertices is a minimal separator.</h2></div></div></div>
<a class="indexterm" name="id-1.25.3.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_is_minimal_separator(const igraph_t *graph,
const igraph_vs_t candidate,
igraph_bool_t *res);
</pre></div>
<p>
</p>
<p>
A vertex separator <code class="constant">S</code> is minimal is no proper subset of <code class="constant">S</code>
is also a separator.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph. It may be directed, but edge
directions are ignored.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>candidate</code></em>:</span></p></td>
<td><p>
The candidate minimal separators.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>res</code></em>:</span></p></td>
<td><p>
Pointer to a boolean variable, the result is stored
here.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(|V|+|E|), linear in the number vertices and edges.
</p>
<div class="hideshow" onClick="toggle(this, event)">
<div class="example">
<a name="id-1.25.3.8.1"></a><p class="title"><b>Example 24.2.  File <code class="code">examples/simple/igraph_is_minimal_separator.c</code></b></p>
<div class="example-contents">
<pre class="programlisting"><span class="strong"><strong>#include</strong></span> &lt;igraph.h&gt;
<span class="strong"><strong>#include</strong></span> &lt;stdio.h&gt;
<span class="strong"><strong>#define</strong></span> <span class="strong"><strong>FAIL</strong></span>(msg, error) <span class="strong"><strong>do</strong></span> { <span class="strong"><strong>printf</strong></span>(msg "\n") ; <span class="strong"><strong>return</strong></span> error; } <span class="strong"><strong>while</strong></span> (0)
int <span class="strong"><strong>main</strong></span>(void) {
igraph_t graph;
igraph_vector_int_t sep;
igraph_bool_t result;
<span class="emphasis"><em>/* Initialize the library. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_setup" title="4.1. igraph_setup — Initializes the igraph library.">igraph_setup</a></strong></span>();
<span class="emphasis"><em>/* Simple star graph, remove the center */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Generators.html#igraph_star" title="4.1. igraph_star — Creates a star graph, every vertex connects only to the center.">igraph_star</a></strong></span>(&amp;graph, 10, IGRAPH_STAR_UNDIRECTED, 0);
<span class="strong"><strong><a class="link" href="igraph-Separators.html#igraph_is_minimal_separator" title="2. igraph_is_minimal_separator — Decides whether a set of vertices is a minimal separator.">igraph_is_minimal_separator</a></strong></span>(&amp;graph, <span class="strong"><strong><a class="link" href="igraph-Iterators.html#igraph_vss_1" title="4.3. igraph_vss_1 — Vertex set with a single vertex (immediate version).">igraph_vss_1</a></strong></span>(0), &amp;result);
<span class="strong"><strong>if</strong></span> (!result) {
<span class="strong"><strong>FAIL</strong></span>("Center of star graph failed.", 1);
}
<span class="emphasis"><em>/* Same graph, but another vertex */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Separators.html#igraph_is_minimal_separator" title="2. igraph_is_minimal_separator — Decides whether a set of vertices is a minimal separator.">igraph_is_minimal_separator</a></strong></span>(&amp;graph, <span class="strong"><strong><a class="link" href="igraph-Iterators.html#igraph_vss_1" title="4.3. igraph_vss_1 — Vertex set with a single vertex (immediate version).">igraph_vss_1</a></strong></span>(6), &amp;result);
<span class="strong"><strong>if</strong></span> (result) {
<span class="strong"><strong>FAIL</strong></span>("Non-center of star graph failed.", 2);
}
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(&amp;graph);
<span class="emphasis"><em>/* Karate club */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Generators.html#igraph_famous" title="8.1. igraph_famous — Create a famous graph by simply providing its name.">igraph_famous</a></strong></span>(&amp;graph, "zachary");
<span class="strong"><strong>igraph_vector_int_init</strong></span>(&amp;sep, 0);
<span class="strong"><strong>igraph_vector_int_push_back</strong></span>(&amp;sep, 32);
<span class="strong"><strong>igraph_vector_int_push_back</strong></span>(&amp;sep, 33);
<span class="strong"><strong><a class="link" href="igraph-Separators.html#igraph_is_minimal_separator" title="2. igraph_is_minimal_separator — Decides whether a set of vertices is a minimal separator.">igraph_is_minimal_separator</a></strong></span>(&amp;graph, <span class="strong"><strong><a class="link" href="igraph-Iterators.html#igraph_vss_vector" title="4.4. igraph_vss_vector — Vertex set based on a vector (immediate version).">igraph_vss_vector</a></strong></span>(&amp;sep), &amp;result);
<span class="strong"><strong>if</strong></span> (!result) {
<span class="strong"><strong>FAIL</strong></span>("Karate network (32,33) failed", 3);
}
<span class="strong"><strong>igraph_vector_int_resize</strong></span>(&amp;sep, 5);
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#VECTOR" title="2.4.1. VECTOR — Accessing an element of a vector.">VECTOR</a></strong></span>(sep)[0] = 8;
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#VECTOR" title="2.4.1. VECTOR — Accessing an element of a vector.">VECTOR</a></strong></span>(sep)[1] = 9;
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#VECTOR" title="2.4.1. VECTOR — Accessing an element of a vector.">VECTOR</a></strong></span>(sep)[2] = 19;
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#VECTOR" title="2.4.1. VECTOR — Accessing an element of a vector.">VECTOR</a></strong></span>(sep)[3] = 30;
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#VECTOR" title="2.4.1. VECTOR — Accessing an element of a vector.">VECTOR</a></strong></span>(sep)[4] = 31;
<span class="strong"><strong><a class="link" href="igraph-Separators.html#igraph_is_minimal_separator" title="2. igraph_is_minimal_separator — Decides whether a set of vertices is a minimal separator.">igraph_is_minimal_separator</a></strong></span>(&amp;graph, <span class="strong"><strong><a class="link" href="igraph-Iterators.html#igraph_vss_vector" title="4.4. igraph_vss_vector — Vertex set based on a vector (immediate version).">igraph_vss_vector</a></strong></span>(&amp;sep), &amp;result);
<span class="strong"><strong>if</strong></span> (result) {
<span class="strong"><strong>FAIL</strong></span>("Karate network (8,9,19,30,31) failed", 4);
}
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(&amp;graph);
<span class="strong"><strong>igraph_vector_int_destroy</strong></span>(&amp;sep);
<span class="strong"><strong>return</strong></span> 0;
}
</pre>
<p></p>
</div>
</div>
<br class="example-break">
</div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="igraph_all_minimal_st_separators"></a>3. <code class="function">igraph_all_minimal_st_separators</code> — List all vertex sets that are minimal (s,t) separators for some s and t.</h2></div></div></div>
<a class="indexterm" name="id-1.25.4.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_all_minimal_st_separators(
const igraph_t *graph, igraph_vector_int_list_t *separators
);
</pre></div>
<p>
</p>
<p>
This function lists all vertex sets that are minimal (s,t)
separators for some (s,t) vertex pair.
</p>
<p>
Note that some vertex sets returned by this function may not be minimal
with respect to disconnecting the graph (or increasing the number of
connected components). Take for example the 5-vertex graph with edges
<code class="literal">0-1-2-3-4-1</code>. This function returns the vertex sets
<code class="literal">{1}</code>, <code class="literal">{2,4}</code> and <code class="literal">{1,3}</code>.
Notice that <code class="literal">{1,3}</code> is not minimal with respect to disconnecting
the graph, as <code class="literal">{1}</code> would be sufficient for that. However, it is
minimal with respect to separating vertices <code class="constant">2</code> and <code class="constant">4</code>.
</p>
<p>
See more about the implemented algorithm in
Anne Berry, Jean-Paul Bordat and Olivier Cogis: Generating All the
Minimal Separators of a Graph, In: Peter Widmayer, Gabriele Neyer
and Stephan Eidenbenz (editors): Graph-theoretic concepts in
computer science, 1665, 167--172, 1999. Springer.
<a class="ulink" href="https://doi.org/10.1007/3-540-46784-X_17" target="_top">https://doi.org/10.1007/3-540-46784-X_17</a>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph. It may be directed, but edge
directions are ignored.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>separators</code></em>:</span></p></td>
<td><p>
Pointer to a list of integer vectors, the separators
will be stored here.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Separators.html#igraph_minimum_size_separators" title="4. igraph_minimum_size_separators — Find all minimum size separating vertex sets."><code class="function">igraph_minimum_size_separators()</code></a>
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n|V|^3), |V| is the number of vertices, n is the
number of separators.
</p>
<div class="hideshow" onClick="toggle(this, event)">
<div class="example">
<a name="id-1.25.4.12.1"></a><p class="title"><b>Example 24.3.  File <code class="code">examples/simple/igraph_minimal_separators.c</code></b></p>
<div class="example-contents">
<pre class="programlisting"><span class="strong"><strong>#include</strong></span> &lt;igraph.h&gt;
<span class="strong"><strong>#include</strong></span> &lt;stdio.h&gt;
int <span class="strong"><strong>main</strong></span>(void) {
igraph_t graph;
igraph_vector_int_list_t separators;
igraph_int_t i, n;
<span class="emphasis"><em>/* Initialize the library. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_setup" title="4.1. igraph_setup — Initializes the igraph library.">igraph_setup</a></strong></span>();
<span class="strong"><strong><a class="link" href="igraph-Generators.html#igraph_famous" title="8.1. igraph_famous — Create a famous graph by simply providing its name.">igraph_famous</a></strong></span>(&amp;graph, "zachary");
<span class="strong"><strong>igraph_vector_int_list_init</strong></span>(&amp;separators, 0);
<span class="strong"><strong><a class="link" href="igraph-Separators.html#igraph_all_minimal_st_separators" title="3. igraph_all_minimal_st_separators — List all vertex sets that are minimal (s,t) separators for some s and t.">igraph_all_minimal_st_separators</a></strong></span>(&amp;graph, &amp;separators);
n = <span class="strong"><strong>igraph_vector_int_list_size</strong></span>(&amp;separators);
<span class="strong"><strong>for</strong></span> (i = 0; i &lt; n; i++) {
igraph_bool_t res;
igraph_vector_int_t *sep = <span class="strong"><strong>igraph_vector_int_list_get_ptr</strong></span>(&amp;separators, i);
<span class="strong"><strong><a class="link" href="igraph-Separators.html#igraph_is_separator" title="1. igraph_is_separator — Would removing this set of vertices disconnect the graph?">igraph_is_separator</a></strong></span>(&amp;graph, <span class="strong"><strong><a class="link" href="igraph-Iterators.html#igraph_vss_vector" title="4.4. igraph_vss_vector — Vertex set based on a vector (immediate version).">igraph_vss_vector</a></strong></span>(sep), &amp;res);
<span class="strong"><strong>if</strong></span> (!res) {
<span class="strong"><strong>printf</strong></span>("Vertex set %" IGRAPH_PRId " is not a separator!\n", i);
<span class="strong"><strong>igraph_vector_int_print</strong></span>(sep);
<span class="strong"><strong>return</strong></span> 1;
}
}
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(&amp;graph);
<span class="strong"><strong>igraph_vector_int_list_destroy</strong></span>(&amp;separators);
<span class="strong"><strong>return</strong></span> 0;
}
</pre>
<p></p>
</div>
</div>
<br class="example-break">
</div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="igraph_minimum_size_separators"></a>4. <code class="function">igraph_minimum_size_separators</code> — Find all minimum size separating vertex sets.</h2></div></div></div>
<a class="indexterm" name="id-1.25.5.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_minimum_size_separators(
const igraph_t *graph, igraph_vector_int_list_t *separators
);
</pre></div>
<p>
</p>
<p>
This function lists all separator vertex sets of minimum size.
A vertex set is a separator if its removal disconnects the graph.
</p>
<p>
If the graph is already disconnected, no separators are returned.
Note that this convention differs from that used by some other
funtions such as <a class="link" href="igraph-Separators.html#igraph_all_minimal_st_separators" title="3. igraph_all_minimal_st_separators — List all vertex sets that are minimal (s,t) separators for some s and t."><code class="function">igraph_all_minimal_st_separators()</code></a>.
</p>
<p>
Complete graphs have no vertex separators.
</p>
<p>
The implementation is based on the following paper:
Arkady Kanevsky: Finding all minimum-size separating vertex sets in
a graph, Networks 23, 533--541, 1993.
<a class="ulink" href="https://doi.org/10.1002/net.3230230604" target="_top">https://doi.org/10.1002/net.3230230604</a>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph, which must be undirected.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>separators</code></em>:</span></p></td>
<td><p>
An initialized list of integer vectors, the separators
are stored here. It is a list of pointers to <span class="type">igraph_vector_int_t</span>
objects. Each vector will contain the IDs of the vertices in
the separator. The separators are returned in an arbitrary order.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: TODO.
</p>
<div class="hideshow" onClick="toggle(this, event)">
<div class="example">
<a name="id-1.25.5.11.1"></a><p class="title"><b>Example 24.4.  File <code class="code">examples/simple/igraph_minimum_size_separators.c</code></b></p>
<div class="example-contents">
<pre class="programlisting"><span class="strong"><strong>#include</strong></span> &lt;igraph.h&gt;
int <span class="strong"><strong>main</strong></span>(void) {
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_setup" title="4.1. igraph_setup — Initializes the igraph library.">igraph_setup</a></strong></span>();
igraph_t g;
igraph_vector_int_list_t sep;
<span class="strong"><strong><a class="link" href="igraph-Generators.html#igraph_small" title="2.2. igraph_small — Shorthand to create a small graph, giving the edges as arguments.">igraph_small</a></strong></span>(&amp;g, 7, IGRAPH_UNDIRECTED,
1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0,
-1);
<span class="strong"><strong>igraph_vector_int_list_init</strong></span>(&amp;sep, 0);
<span class="strong"><strong><a class="link" href="igraph-Separators.html#igraph_minimum_size_separators" title="4. igraph_minimum_size_separators — Find all minimum size separating vertex sets.">igraph_minimum_size_separators</a></strong></span>(&amp;g, &amp;sep);
<span class="strong"><strong>for</strong></span> (igraph_int_t i = 0; i &lt; <span class="strong"><strong>igraph_vector_int_list_size</strong></span>(&amp;sep); i++) {
igraph_vector_int_t* v = <span class="strong"><strong>igraph_vector_int_list_get_ptr</strong></span>(&amp;sep, i);
<span class="strong"><strong>igraph_vector_int_print</strong></span>(v);
}
<span class="strong"><strong>igraph_vector_int_list_destroy</strong></span>(&amp;sep);
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(&amp;g);
<span class="strong"><strong>return</strong></span> 0;
}
</pre>
<p></p>
</div>
</div>
<br class="example-break">
</div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="igraph_even_tarjan_reduction"></a>5. <code class="function">igraph_even_tarjan_reduction</code> — Even-Tarjan reduction of a graph.</h2></div></div></div>
<a class="indexterm" name="id-1.25.6.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_even_tarjan_reduction(const igraph_t *graph, igraph_t *graphbar,
igraph_vector_t *capacity);
</pre></div>
<p>
</p>
<p>
A digraph is created with twice as many vertices and edges. For each
original vertex <code class="constant">i</code>, two vertices <code class="literal">i' = i</code> and
<code class="literal">i'' = i' + n</code> are created,
with a directed edge from <code class="literal">i'</code> to <code class="literal">i''</code>.
For each original directed edge from <code class="constant">i</code> to <code class="constant">j</code>, two new edges are created,
from <code class="literal">i'</code> to <code class="literal">j''</code> and from <code class="literal">i''</code>
to <code class="literal">j'</code>.
</p>
<p>This reduction is used in the paper (observation 2):
Arkady Kanevsky: Finding all minimum-size separating vertex sets in
a graph, Networks 23, 533--541, 1993.
</p>
<p>The original paper where this reduction was conceived is
Shimon Even and R. Endre Tarjan: Network Flow and Testing Graph
Connectivity, SIAM J. Comput., 4(4), 507518.
<a class="ulink" href="https://doi.org/10.1137/0204043" target="_top">https://doi.org/10.1137/0204043</a>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
A graph. Although directness is not checked, this function
is commonly used only on directed graphs.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>graphbar</code></em>:</span></p></td>
<td><p>
Pointer to a new directed graph that will contain the
reduction, with twice as many vertices and edges.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>capacity</code></em>:</span></p></td>
<td><p>
Pointer to an initialized vector or a null pointer. If
not a null pointer, then it will be filled the capacity from
the reduction: the first |E| elements are 1, the remaining |E|
are equal to |V| (which is used to indicate infinity).
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(|E|+|V|).
</p>
<div class="hideshow" onClick="toggle(this, event)">
<div class="example">
<a name="id-1.25.6.10.1"></a><p class="title"><b>Example 24.5.  File <code class="code">examples/simple/even_tarjan.c</code></b></p>
<div class="example-contents">
<pre class="programlisting"><span class="strong"><strong>#include</strong></span> &lt;igraph.h&gt;
<span class="strong"><strong>#include</strong></span> &lt;limits.h&gt;
int <span class="strong"><strong>main</strong></span>(void) {
igraph_t g, gbar;
igraph_int_t k1, k2 = INT_MAX;
igraph_real_t tmpk;
igraph_int_t i, j, n;
<a class="link" href="igraph-Flows.html#igraph_maxflow_stats_t" title="1.4. igraph_maxflow_stats_t — Data structure holding statistics from the push-relabel maximum flow solver.">igraph_maxflow_stats_t</a> stats;
<span class="emphasis"><em>/* Initialize the library. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_setup" title="4.1. igraph_setup — Initializes the igraph library.">igraph_setup</a></strong></span>();
<span class="strong"><strong><a class="link" href="igraph-Generators.html#igraph_famous" title="8.1. igraph_famous — Create a famous graph by simply providing its name.">igraph_famous</a></strong></span>(&amp;g, "meredith");
<span class="strong"><strong><a class="link" href="igraph-Separators.html#igraph_even_tarjan_reduction" title="5. igraph_even_tarjan_reduction — Even-Tarjan reduction of a graph.">igraph_even_tarjan_reduction</a></strong></span>(&amp;g, &amp;gbar, <span class="emphasis"><em>/*capacity=*/</em></span> NULL);
<span class="strong"><strong><a class="link" href="igraph-Flows.html#igraph_vertex_connectivity" title="3.4. igraph_vertex_connectivity — The vertex connectivity of a graph.">igraph_vertex_connectivity</a></strong></span>(&amp;g, &amp;k1, <span class="emphasis"><em>/* checks= */</em></span> false);
n = <span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_vcount" title="5.2.1. igraph_vcount — The number of vertices in a graph.">igraph_vcount</a></strong></span>(&amp;g);
<span class="strong"><strong>for</strong></span> (i = 0; i &lt; n; i++) {
<span class="strong"><strong>for</strong></span> (j = i + 1; j &lt; n; j++) {
igraph_bool_t conn;
<span class="strong"><strong><a class="link" href="igraph-Structural.html#igraph_are_adjacent" title="1.1. igraph_are_adjacent — Decides whether two vertices are adjacent.">igraph_are_adjacent</a></strong></span>(&amp;g, i, j, &amp;conn);
<span class="strong"><strong>if</strong></span> (conn) {
<span class="strong"><strong>continue</strong></span>;
}
<span class="strong"><strong><a class="link" href="igraph-Flows.html#igraph_maxflow_value" title="1.2. igraph_maxflow_value — Maximum flow in a network with the push/relabel algorithm.">igraph_maxflow_value</a></strong></span>(&amp;gbar, &amp;tmpk,
<span class="emphasis"><em>/* source= */</em></span> i + n,
<span class="emphasis"><em>/* target= */</em></span> j,
<span class="emphasis"><em>/* capacity= */</em></span> 0,
&amp;stats);
<span class="strong"><strong>if</strong></span> (tmpk &lt; k2) {
k2 = tmpk;
}
}
}
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(&amp;gbar);
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(&amp;g);
<span class="strong"><strong>if</strong></span> (k1 != k2) {
<span class="strong"><strong>printf</strong></span>("k1 = %" IGRAPH_PRId " while k2 = %" IGRAPH_PRId "\n", k1, k2);
<span class="strong"><strong>return</strong></span> 1;
}
<span class="strong"><strong>return</strong></span> 0;
}
</pre>
<p></p>
</div>
</div>
<br class="example-break">
</div>
<p>
</p>
</div>
</div>
<table class="navigation-footer" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle">
<td align="left"><a accesskey="p" href="igraph-Flows.html"><b>← Chapter 23. Maximum flows, minimum cuts and related measures</b></a></td>
<td align="right"><a accesskey="n" href="igraph-Community.html"><b>Chapter 25. Detecting community structure →</b></a></td>
</tr></table>
</body>
</html>