1 /* -*- mode: C -*- */
2 /*
3 IGraph library.
4 Copyright (C) 2006-2012 Gabor Csardi <csardi.gabor@gmail.com>
5 334 Harvard street, Cambridge, MA 02139 USA
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301 USA
21
22 */
23
24 #include <igraph.h>
25
main()26 int main() {
27
28 igraph_t g1, g2;
29
30 /* complementer of the empty graph */
31 igraph_empty(&g1, 5, IGRAPH_DIRECTED);
32 igraph_complementer(&g2, &g1, IGRAPH_LOOPS);
33 igraph_write_graph_edgelist(&g2, stdout);
34 igraph_destroy(&g1);
35 igraph_destroy(&g2);
36
37 printf("---\n");
38
39 /* the same without loops */
40 igraph_empty(&g1, 5, IGRAPH_DIRECTED);
41 igraph_complementer(&g2, &g1, IGRAPH_NO_LOOPS);
42 igraph_write_graph_edgelist(&g2, stdout);
43 igraph_destroy(&g1);
44 igraph_destroy(&g2);
45
46 printf("---\n");
47
48 /* complementer of the full graph */
49 igraph_full(&g1, 5, IGRAPH_DIRECTED, IGRAPH_LOOPS);
50 igraph_complementer(&g2, &g1, IGRAPH_LOOPS);
51 if (igraph_ecount(&g2) != 0) {
52 return 1;
53 }
54 igraph_destroy(&g1);
55 igraph_destroy(&g2);
56
57 printf("---\n");
58
59 /* complementer of the full graph, results loops only */
60 igraph_full(&g1, 5, IGRAPH_DIRECTED, IGRAPH_NO_LOOPS);
61 igraph_complementer(&g2, &g1, IGRAPH_LOOPS);
62 igraph_write_graph_edgelist(&g2, stdout);
63 igraph_destroy(&g1);
64 igraph_destroy(&g2);
65
66 printf("---\n");
67
68 /**************
69 * undirected *
70 *************/
71
72 /* complementer of the empty graph */
73 igraph_empty(&g1, 5, IGRAPH_UNDIRECTED);
74 igraph_complementer(&g2, &g1, IGRAPH_LOOPS);
75 igraph_write_graph_edgelist(&g2, stdout);
76 igraph_destroy(&g1);
77 igraph_destroy(&g2);
78
79 printf("---\n");
80
81 /* the same without loops */
82 igraph_empty(&g1, 5, IGRAPH_UNDIRECTED);
83 igraph_complementer(&g2, &g1, IGRAPH_NO_LOOPS);
84 igraph_write_graph_edgelist(&g2, stdout);
85 igraph_destroy(&g1);
86 igraph_destroy(&g2);
87
88 printf("---\n");
89
90 /* complementer of the full graph */
91 igraph_full(&g1, 5, IGRAPH_UNDIRECTED, IGRAPH_LOOPS);
92 igraph_complementer(&g2, &g1, IGRAPH_LOOPS);
93 if (igraph_ecount(&g2) != 0) {
94 return 1;
95 }
96 igraph_destroy(&g1);
97 igraph_destroy(&g2);
98
99 printf("---\n");
100
101 /* complementer of the full graph, results loops only */
102 igraph_full(&g1, 5, IGRAPH_UNDIRECTED, IGRAPH_NO_LOOPS);
103 igraph_complementer(&g2, &g1, IGRAPH_LOOPS);
104 igraph_write_graph_edgelist(&g2, stdout);
105 igraph_destroy(&g1);
106 igraph_destroy(&g2);
107
108 return 0;
109 }
110