For using the igraph C library
These functions calculate various graph properties related to cliques and independent vertex sets.
igraph_is_complete
— Decides whether the graph is complete.igraph_is_clique
— Does a set of vertices form a clique?igraph_cliques
— Finds all or some cliques in a graph.igraph_clique_size_hist
— Counts cliques of each size in the graph.igraph_cliques_callback
— Calls a function for each clique in the graph.igraph_clique_handler_t
— Type of clique handler functions.igraph_largest_cliques
— Finds the largest clique(s) in a graph.igraph_maximal_cliques
— Finds all maximal cliques in a graph.igraph_maximal_cliques_count
— Count the number of maximal cliques in a graph.igraph_maximal_cliques_file
— Find maximal cliques and write them to a file.igraph_maximal_cliques_subset
— Maximal cliques for a subset of initial vertices.igraph_maximal_cliques_hist
— Counts the number of maximal cliques of each size in a graph.igraph_maximal_cliques_callback
— Finds maximal cliques in a graph and calls a function for each one.igraph_clique_number
— Finds the clique number of the graph.
igraph_error_t igraph_is_complete(const igraph_t *graph, igraph_bool_t *res);
This function is experimental and its signature is not considered final yet. We reserve the right to change the function signature without changing the major version of igraph. Use it at your own risk.
A graph is considered complete if all pairs of different vertices are adjacent.
The null graph and the singleton graph are considered complete.
Arguments:
|
The graph object to analyze. |
|
Pointer to a logical variable, the result will be stored here. |
Returns:
Error code. |
Time complexity: O(|V| + |E|) at worst.
igraph_error_t igraph_is_clique(const igraph_t *graph, igraph_vs_t candidate, igraph_bool_t directed, igraph_bool_t *res);
This function is experimental and its signature is not considered final yet. We reserve the right to change the function signature without changing the major version of igraph. Use it at your own risk.
Tests if all pairs within a set of vertices are adjacent, i.e. whether they form a clique. An empty set and singleton set are considered to be a clique.
Arguments:
|
The input graph. |
|
The vertex set to test for being a clique. |
|
Whether to take edge directions into account in directed graphs. |
|
The result will be stored here. |
Returns:
Error code. |
See also:
Time complexity: O(n^2 log(d)) where n is the number of vertices in the candidate set and d is the typical vertex degree.
igraph_error_t igraph_cliques(const igraph_t *graph, igraph_vector_int_list_t *res, igraph_integer_t min_size, igraph_integer_t max_size);
Cliques are fully connected subgraphs of a graph.
If you are only interested in the size of the largest clique in the graph,
use igraph_clique_number()
instead.
The current implementation of this function uses version 1.21 of the Cliquer library by Sampo Niskanen and Patric R. J. Östergård, http://users.aalto.fi/~pat/cliquer.html
Arguments:
|
The input graph. |
|
Pointer to an initialized list of integer vectors. The cliques will be stored here as vectors of vertex IDs. |
|
Integer specifying the minimum size of the cliques to be returned. If negative or zero, no lower bound will be used. |
|
Integer specifying the maximum size of the cliques to be returned. If negative or zero, no upper bound will be used. |
Returns:
Error code. |
See also:
Time complexity: Exponential
Example 16.1. File examples/simple/igraph_cliques.c
#include <igraph.h> #include <stdlib.h> int compare_vectors(const igraph_vector_int_t *v1, const igraph_vector_int_t *v2) { igraph_integer_t s1, s2, i; s1 = igraph_vector_int_size(v1); s2 = igraph_vector_int_size(v2); if (s1 < s2) { return -1; } if (s1 > s2) { return 1; } for (i = 0; i < s1; ++i) { if (VECTOR(*v1)[i] < VECTOR(*v2)[i]) { return -1; } if (VECTOR(*v1)[i] > VECTOR(*v2)[i]) { return 1; } } return 0; } /* Takes a pointer vector of vectors. Sorts each vector, then sorts the pointer vector */ void canonicalize_list(igraph_vector_int_list_t *list) { igraph_integer_t len = igraph_vector_int_list_size(list); for (igraph_integer_t i = 0; i < len; ++i) { igraph_vector_int_sort(igraph_vector_int_list_get_ptr(list, i)); } igraph_vector_int_list_sort(list, &compare_vectors); } struct userdata { igraph_integer_t i; igraph_vector_int_list_t *list; }; igraph_error_t handler(const igraph_vector_int_t *clique, void *arg) { struct userdata *ud; igraph_bool_t cont; ud = (struct userdata *) arg; cont = 1; /* true */ if (compare_vectors(clique, igraph_vector_int_list_get_ptr(ud->list, ud->i)) != 0) { printf("igraph_cliques() and igraph_cliques_callback() give different results.\n"); cont = 0; /* false */ } ud->i += 1; return cont ? IGRAPH_SUCCESS : IGRAPH_STOP; } void test_callback(const igraph_t *graph) { igraph_vector_int_list_t list; struct userdata ud; igraph_vector_int_list_init(&list, 0); igraph_cliques(graph, &list, 0, 0); ud.i = 0; ud.list = &list; igraph_cliques_callback(graph, 0, 0, &handler, (void *) &ud); igraph_vector_int_list_destroy(&list); } int main(void) { igraph_t g; igraph_vector_int_list_t result; igraph_es_t es; igraph_integer_t omega; igraph_integer_t i, j, n; const int params[] = {4, -1, 2, 2, 0, 0, -1, -1}; igraph_set_warning_handler(igraph_warning_handler_ignore); igraph_vector_int_list_init(&result, 0); igraph_full(&g, 6, 0, 0); igraph_es_pairs_small(&es, 0, 0, 1, 0, 2, 3, 5, -1); igraph_delete_edges(&g, es); igraph_es_destroy(&es); for (j = 0; j < sizeof(params) / (2 * sizeof(params[0])); j++) { if (params[2 * j + 1] != 0) { igraph_cliques(&g, &result, params[2 * j], params[2 * j + 1]); } else { igraph_largest_cliques(&g, &result); } n = igraph_vector_int_list_size(&result); printf("%" IGRAPH_PRId " cliques found\n", n); canonicalize_list(&result); for (i = 0; i < n; i++) { igraph_vector_int_t* v = igraph_vector_int_list_get_ptr(&result, i); igraph_vector_int_print(v); } } igraph_clique_number(&g, &omega); printf("omega=%" IGRAPH_PRId "\n", omega); test_callback(&g); igraph_destroy(&g); igraph_kary_tree(&g, 5, 2, IGRAPH_TREE_OUT); igraph_cliques(&g, &result, 5, 5); if (igraph_vector_int_list_size(&result) != 0) { return 1; } igraph_destroy(&g); igraph_vector_int_list_destroy(&result); return 0; }
igraph_error_t igraph_clique_size_hist(const igraph_t *graph, igraph_vector_t *hist, igraph_integer_t min_size, igraph_integer_t max_size);
Cliques are fully connected subgraphs of a graph.
The current implementation of this function uses version 1.21 of the Cliquer library by Sampo Niskanen and Patric R. J. Östergård, http://users.aalto.fi/~pat/cliquer.html
Arguments:
|
The input graph. |
|
Pointer to an initialized vector. The result will be stored
here. The first element will store the number of size-1 cliques, the second
element the number of size-2 cliques, etc. For cliques smaller than |
|
Integer specifying the minimum size of the cliques to be returned. If negative or zero, no lower bound will be used. |
|
Integer specifying the maximum size of the cliques to be returned. If negative or zero, no upper bound will be used. |
Returns:
Error code. |
See also:
Time complexity: Exponential
igraph_error_t igraph_cliques_callback(const igraph_t *graph, igraph_integer_t min_size, igraph_integer_t max_size, igraph_clique_handler_t *cliquehandler_fn, void *arg);
Cliques are fully connected subgraphs of a graph. This function
enumerates all cliques within the given size range and calls
cliquehandler_fn
for each of them. The cliques are passed to the
callback function as a pointer to an igraph_vector_int_t
. Destroying and
freeing this vector is left up to the user. Use igraph_vector_int_destroy()
to destroy it first, then free it using igraph_free()
.
The current implementation of this function uses version 1.21 of the Cliquer library by Sampo Niskanen and Patric R. J. Östergård, http://users.aalto.fi/~pat/cliquer.html
Arguments:
|
The input graph. |
|
Integer specifying the minimum size of the cliques to be returned. If negative or zero, no lower bound will be used. |
|
Integer specifying the maximum size of the cliques to be returned. If negative or zero, no upper bound will be used. |
|
Callback function to be called for each clique.
See also |
|
Extra argument to supply to |
Returns:
Error code. |
See also:
Time complexity: Exponential
typedef igraph_error_t igraph_clique_handler_t(const igraph_vector_int_t *clique, void *arg);
Callback type, called when a clique was found.
See the details at the documentation of igraph_cliques_callback()
.
Arguments:
|
The current clique. The clique is owned by the clique search routine. You do not need to destroy or free it if you do not want to store it; however, if you want to hold on to it for a longer period of time, you need to make a copy of it on your own and store the copy itself. |
|
This extra argument was passed to |
Returns:
Error code; |
igraph_error_t igraph_largest_cliques(const igraph_t *graph, igraph_vector_int_list_t *res);
A clique is largest (quite intuitively) if there is no other clique in the graph which contains more vertices.
Note that this is not necessarily the same as a maximal clique, i.e. the largest cliques are always maximal but a maximal clique is not always largest.
The current implementation of this function searches
for maximal cliques using igraph_maximal_cliques_callback()
and drops
those that are not the largest.
The implementation of this function changed between igraph 0.5 and 0.6, so the order of the cliques and the order of vertices within the cliques will almost surely be different between these two versions.
Arguments:
|
The input graph. |
|
Pointer to an initialized list of integer vectors. The cliques will be stored here as vectors of vertex IDs. |
Returns:
Error code. |
See also:
Time complexity: O(3^(|V|/3)) worst case.
igraph_error_t igraph_maximal_cliques( const igraph_t *graph, igraph_vector_int_list_t *res, igraph_integer_t min_size, igraph_integer_t max_size );
A maximal clique is a clique which can't be extended any more by adding a new vertex to it.
If you are only interested in the size of the largest clique in the
graph, use igraph_clique_number()
instead.
The current implementation uses a modified Bron-Kerbosch algorithm to find the maximal cliques, see: David Eppstein, Maarten Löffler, Darren Strash: Listing All Maximal Cliques in Sparse Graphs in Near-Optimal Time. Algorithms and Computation, Lecture Notes in Computer Science Volume 6506, 2010, pp 403-414.
The implementation of this function changed between igraph 0.5 and 0.6 and also between 0.6 and 0.7, so the order of the cliques and the order of vertices within the cliques will almost surely be different between these three versions.
Arguments:
|
The input graph. |
|
Pointer to list of integer vectors. The maximal cliques will be returned here as vectors of vertex IDs. Note that vertices of a clique may be returned in arbitrary order. |
|
Integer giving the minimum size of the cliques to be returned. If negative or zero, no lower bound will be used. |
|
Integer giving the maximum size of the cliques to be returned. If negative or zero, no upper bound will be used. |
Returns:
Error code. |
See also:
Time complexity: O(d(n-d)3^(d/3)) worst case, d is the degeneracy of the graph, this is typically small for sparse graphs.
Example 16.2. File examples/simple/igraph_maximal_cliques.c
#include <igraph.h> int main(void) { igraph_t g; igraph_vector_int_list_t cliques; igraph_integer_t no; igraph_small(&g, 9, IGRAPH_UNDIRECTED, 0,1, 0,2, 1,2, 2,3, 3,4, 3, 5, 4,5, 5,6, 6,7, -1); igraph_vector_int_list_init(&cliques, 0); igraph_maximal_cliques(&g, &cliques, /*min_size=*/ 0, /*max_size=*/ 0 /*no limit*/); igraph_maximal_cliques_count(&g, &no, /*min_size=*/ 0, /*max_size=*/ 0 /*no limit*/); if (no != igraph_vector_int_list_size(&cliques)) { return 1; } for (igraph_integer_t i = 0; i < igraph_vector_int_list_size(&cliques); i++) { igraph_vector_int_t *v = igraph_vector_int_list_get_ptr(&cliques, i); igraph_vector_int_print(v); } igraph_vector_int_list_destroy(&cliques); igraph_destroy(&g); return 0; }
igraph_error_t igraph_maximal_cliques_count(const igraph_t *graph, igraph_integer_t *res, igraph_integer_t min_size, igraph_integer_t max_size);
The current implementation uses a modified Bron-Kerbosch algorithm to find the maximal cliques, see: David Eppstein, Maarten Löffler, Darren Strash: Listing All Maximal Cliques in Sparse Graphs in Near-Optimal Time. Algorithms and Computation, Lecture Notes in Computer Science Volume 6506, 2010, pp 403-414.
Arguments:
|
The input graph. |
|
Pointer to an |
|
Integer giving the minimum size of the cliques to be returned. If negative or zero, no lower bound will be used. |
|
Integer giving the maximum size of the cliques to be returned. If negative or zero, no upper bound will be used. |
Returns:
Error code. |
See also:
Time complexity: O(d(n-d)3^(d/3)) worst case, d is the degeneracy of the graph, this is typically small for sparse graphs.
Example 16.3. File examples/simple/igraph_maximal_cliques.c
#include <igraph.h> int main(void) { igraph_t g; igraph_vector_int_list_t cliques; igraph_integer_t no; igraph_small(&g, 9, IGRAPH_UNDIRECTED, 0,1, 0,2, 1,2, 2,3, 3,4, 3, 5, 4,5, 5,6, 6,7, -1); igraph_vector_int_list_init(&cliques, 0); igraph_maximal_cliques(&g, &cliques, /*min_size=*/ 0, /*max_size=*/ 0 /*no limit*/); igraph_maximal_cliques_count(&g, &no, /*min_size=*/ 0, /*max_size=*/ 0 /*no limit*/); if (no != igraph_vector_int_list_size(&cliques)) { return 1; } for (igraph_integer_t i = 0; i < igraph_vector_int_list_size(&cliques); i++) { igraph_vector_int_t *v = igraph_vector_int_list_get_ptr(&cliques, i); igraph_vector_int_print(v); } igraph_vector_int_list_destroy(&cliques); igraph_destroy(&g); return 0; }
igraph_error_t igraph_maximal_cliques_file(const igraph_t *graph, FILE *outfile, igraph_integer_t min_size, igraph_integer_t max_size);
This function enumerates all maximal cliques and writes them to file.
Edge directions are ignored.
Arguments:
|
The input graph. |
|
Pointer to the output file, it should be writable. |
|
Integer giving the minimum size of the cliques to be returned. If negative or zero, no lower bound will be used. |
|
Integer giving the maximum size of the cliques to be returned. If negative or zero, no upper bound will be used. |
Returns:
Error code. |
See also:
Time complexity: O(d(n-d)3^(d/3)) worst case, d is the degeneracy of the graph, this is typically small for sparse graphs.*
igraph_error_t igraph_maximal_cliques_subset( const igraph_t *graph, const igraph_vector_int_t *subset, igraph_vector_int_list_t *res, igraph_integer_t *no, FILE *outfile, igraph_integer_t min_size, igraph_integer_t max_size );
This function enumerates all maximal cliques for a subset of initial vertices and writes them to file.
Edge directions are ignored.
Arguments:
|
The input graph. |
|
Pointer to an |
|
Pointer to a list of integer vectors; the cliques will be stored here |
|
Pointer to an |
|
Pointer to an output file or |
|
Integer giving the minimum size of the cliques to be returned. If negative or zero, no lower bound will be used. |
|
Integer giving the maximum size of the cliques to be returned. If negative or zero, no upper bound will be used. |
Returns:
Error code. |
See also:
Time complexity: O(d(n-d)3^(d/3)) worst case, d is the degeneracy of the graph, this is typically small for sparse graphs.
igraph_error_t igraph_maximal_cliques_hist(const igraph_t *graph, igraph_vector_t *hist, igraph_integer_t min_size, igraph_integer_t max_size);
This function counts how many maximal cliques of each size are present in the graph. Size-1 maximal cliques are simply isolated vertices.
Edge directions are ignored.
Arguments:
|
The input graph. |
|
Pointer to an initialized vector. The result will be stored
here. The first element will store the number of size-1 maximal cliques,
the second element the number of size-2 maximal cliques, etc.
For cliques smaller than |
|
Integer giving the minimum size of the cliques to be returned. If negative or zero, no lower bound will be used. |
|
Integer giving the maximum size of the cliques to be returned. If negative or zero, no upper bound will be used. |
Returns:
Error code. |
See also:
Time complexity: O(d(n-d)3^(d/3)) worst case, d is the degeneracy of the graph, this is typically small for sparse graphs.
igraph_error_t igraph_maximal_cliques_callback(const igraph_t *graph, igraph_clique_handler_t *cliquehandler_fn, void *arg, igraph_integer_t min_size, igraph_integer_t max_size);
This function enumerates all maximal cliques within the given size range
and calls cliquehandler_fn
for each of them. The cliques are passed to the
callback function as a pointer to an igraph_vector_int_t
. The vector is
owned by the maximal clique search routine so users are expected to make a
copy of the vector using igraph_vector_int_init_copy()
if they want to
hold on to it.
Edge directions are ignored.
Arguments:
|
The input graph. |
|
Callback function to be called for each clique.
See also |
|
Extra argument to supply to |
|
Integer giving the minimum size of the cliques to be returned. If negative or zero, no lower bound will be used. |
|
Integer giving the maximum size of the cliques to be returned. If negative or zero, no upper bound will be used. |
Returns:
Error code. |
See also:
Time complexity: O(d(n-d)3^(d/3)) worst case, d is the degeneracy of the graph, this is typically small for sparse graphs.
igraph_error_t igraph_clique_number(const igraph_t *graph, igraph_integer_t *no);
The clique number of a graph is the size of the largest clique.
The current implementation of this function searches
for maximal cliques using igraph_maximal_cliques_callback()
and keeps
track of the size of the largest clique that was found.
Arguments:
|
The input graph. |
|
The clique number will be returned to the |
Returns:
Error code. |
See also:
Time complexity: O(3^(|V|/3)) worst case.
igraph_error_t igraph_weighted_cliques(const igraph_t *graph, const igraph_vector_t *vertex_weights, igraph_vector_int_list_t *res, igraph_real_t min_weight, igraph_real_t max_weight, igraph_bool_t maximal);
Cliques are fully connected subgraphs of a graph. The weight of a clique is the sum of the weights of individual vertices within the clique.
Only positive integer vertex weights are supported.
The current implementation of this function uses version 1.21 of the Cliquer library by Sampo Niskanen and Patric R. J. Östergård, http://users.aalto.fi/~pat/cliquer.html
Arguments:
|
The input graph. |
|
A vector of vertex weights. The current implementation
will truncate all weights to their integer parts. You may pass |
|
Pointer to an initialized list of integer vectors. The cliques will be stored here as vectors of vertex IDs. |
|
Integer specifying the minimum weight of the cliques to be returned. If negative or zero, no lower bound will be used. |
|
Integer specifying the maximum weight of the cliques to be returned. If negative or zero, no upper bound will be used. |
|
If true, only maximal cliques will be returned |
Returns:
Error code. |
See also:
Time complexity: Exponential
igraph_error_t igraph_largest_weighted_cliques(const igraph_t *graph, const igraph_vector_t *vertex_weights, igraph_vector_int_list_t *res);
The weight of a clique is the sum of the weights of its vertices. This function finds the clique(s) having the largest weight in the graph.
Only positive integer vertex weights are supported.
The current implementation of this function uses version 1.21 of the Cliquer library by Sampo Niskanen and Patric R. J. Östergård, http://users.aalto.fi/~pat/cliquer.html
Arguments:
|
The input graph. |
|
A vector of vertex weights. The current implementation
will truncate all weights to their integer parts. You may pass |
|
Pointer to an initialized list of integer vectors. The cliques will be stored here as vectors of vertex IDs. |
Returns:
Error code. |
See also:
Time complexity: TODO
igraph_error_t igraph_weighted_clique_number(const igraph_t *graph, const igraph_vector_t *vertex_weights, igraph_real_t *res);
The weight of a clique is the sum of the weights of its vertices. This function finds the weight of the largest weight clique.
Only positive integer vertex weights are supported.
The current implementation of this function uses version 1.21 of the Cliquer library by Sampo Niskanen and Patric R. J. Östergård, http://users.aalto.fi/~pat/cliquer.html
Arguments:
|
The input graph. |
|
A vector of vertex weights. The current implementation
will truncate all weights to their integer parts. You may pass |
|
The largest weight will be returned to the |
Returns:
Error code. |
See also:
Time complexity: TODO
igraph_is_independent_vertex_set
— Does a set of vertices form an independent set?igraph_independent_vertex_sets
— Finds all independent vertex sets in a graph.igraph_largest_independent_vertex_sets
— Finds the largest independent vertex set(s) in a graph.igraph_maximal_independent_vertex_sets
— Finds all maximal independent vertex sets of a graph.igraph_independence_number
— Finds the independence number of the graph.
igraph_error_t igraph_is_independent_vertex_set(const igraph_t *graph, igraph_vs_t candidate, igraph_bool_t *res);
This function is experimental and its signature is not considered final yet. We reserve the right to change the function signature without changing the major version of igraph. Use it at your own risk.
Tests if no pairs within a set of vertices are adjacenct, i.e. whether they form a an independent set. An empty set and singleton set are both considered to be an independent set.
Arguments:
|
The input graph. |
|
The vertex set to test for being an independent set. |
|
The result will be stored here. |
Returns:
Error code. |
See also:
Time complexity: O(n^2 log(d)) where n is the number of vertices in the candidate set and d is the typical vertex degree.
igraph_error_t igraph_independent_vertex_sets(const igraph_t *graph, igraph_vector_int_list_t *res, igraph_integer_t min_size, igraph_integer_t max_size);
A vertex set is considered independent if there are no edges between them.
If you are interested in the size of the largest independent vertex set,
use igraph_independence_number()
instead.
The current implementation was ported to igraph from the Very Nauty Graph Library by Keith Briggs and uses the algorithm from the paper S. Tsukiyama, M. Ide, H. Ariyoshi and I. Shirawaka. A new algorithm for generating all the maximal independent sets. SIAM J Computing, 6:505--517, 1977.
Arguments:
|
The input graph. |
|
Pointer to an initialized list of integer vectors. The cliques will be stored here as vectors of vertex IDs. |
|
Integer specifying the minimum size of the sets to be returned. If negative or zero, no lower bound will be used. |
|
Integer specifying the maximum size of the sets to be returned. If negative or zero, no upper bound will be used. |
Returns:
Error code. |
See also:
Time complexity: TODO
Example 16.4. File examples/simple/igraph_independent_sets.c
#include <igraph.h> #include <stdlib.h> int main(void) { igraph_t g; igraph_vector_int_list_t result; igraph_integer_t i, j, n; igraph_integer_t alpha; const int params[] = {4, -1, 2, 2, 0, 0, -1, -1}; igraph_set_warning_handler(igraph_warning_handler_ignore); igraph_vector_int_list_init(&result, 0); igraph_kary_tree(&g, 5, 2, IGRAPH_TREE_OUT); for (j = 0; j < sizeof(params) / (2 * sizeof(params[0])); j++) { if (params[2 * j + 1] != 0) { igraph_independent_vertex_sets(&g, &result, params[2 * j], params[2 * j + 1]); } else { igraph_largest_independent_vertex_sets(&g, &result); } n = igraph_vector_int_list_size(&result); printf("%" IGRAPH_PRId " independent sets found\n", n); for (i = 0; i < n; i++) { igraph_vector_int_print(igraph_vector_int_list_get_ptr(&result, i)); } } igraph_destroy(&g); igraph_kary_tree(&g, 10, 2, IGRAPH_TREE_OUT); igraph_maximal_independent_vertex_sets(&g, &result); n = igraph_vector_int_list_size(&result); printf("%" IGRAPH_PRId " maximal independent sets found\n", n); for (i = 0; i < n; i++) { igraph_vector_int_print(igraph_vector_int_list_get_ptr(&result, i)); } igraph_independence_number(&g, &alpha); printf("alpha=%" IGRAPH_PRId "\n", alpha); igraph_destroy(&g); igraph_vector_int_list_destroy(&result); return 0; }
igraph_error_t igraph_largest_independent_vertex_sets(const igraph_t *graph, igraph_vector_int_list_t *res);
An independent vertex set is largest if there is no other independent vertex set with more vertices in the graph.
The current implementation was ported to igraph from the Very Nauty Graph Library by Keith Briggs and uses the algorithm from the paper S. Tsukiyama, M. Ide, H. Ariyoshi and I. Shirawaka. A new algorithm for generating all the maximal independent sets. SIAM J Computing, 6:505--517, 1977.
Arguments:
|
The input graph. |
|
Pointer to an initialized list of integer vectors. The cliques will be stored here as vectors of vertex IDs. |
Returns:
Error code. |
See also:
Time complexity: TODO
igraph_error_t igraph_maximal_independent_vertex_sets(const igraph_t *graph, igraph_vector_int_list_t *res);
A maximal independent vertex set is an independent vertex set which can't be extended any more by adding a new vertex to it.
The algorithm used here is based on the following paper: S. Tsukiyama, M. Ide, H. Ariyoshi and I. Shirawaka. A new algorithm for generating all the maximal independent sets. SIAM J Computing, 6:505--517, 1977.
The implementation was originally written by Kevin O'Neill and modified by K M Briggs in the Very Nauty Graph Library. I simply re-wrote it to use igraph's data structures.
If you are interested in the size of the largest independent vertex set,
use igraph_independence_number()
instead.
Arguments:
|
The input graph. |
|
Pointer to an initialized list of integer vectors. The cliques will be stored here as vectors of vertex IDs. |
Returns:
Error code. |
See also:
Time complexity: TODO.
igraph_error_t igraph_independence_number(const igraph_t *graph, igraph_integer_t *no);
The independence number of a graph is the cardinality of the largest independent vertex set.
The current implementation was ported to igraph from the Very Nauty Graph Library by Keith Briggs and uses the algorithm from the paper S. Tsukiyama, M. Ide, H. Ariyoshi and I. Shirawaka. A new algorithm for generating all the maximal independent sets. SIAM J Computing, 6:505--517, 1977.
Arguments:
|
The input graph. |
|
The independence number will be returned to the |
Returns:
Error code. |
See also:
Time complexity: TODO.
← Chapter 15. Graph visitors | Chapter 17. Graph isomorphism → |