1 /* -*- mode: C -*- */
2 /*
3 IGraph library.
4 Copyright (C) 2006-2012 Gabor Csardi <csardi.gabor@gmail.com>
5 334 Harvard st, 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 g;
29
30 /* Multiple edges */
31
32 igraph_small(&g, 0, IGRAPH_DIRECTED, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, -1);
33 igraph_simplify(&g, 1, 1, /*edge_comb=*/ 0);
34 igraph_write_graph_edgelist(&g, stdout);
35 igraph_destroy(&g);
36
37 igraph_small(&g, 0, IGRAPH_UNDIRECTED, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, -1);
38 igraph_simplify(&g, 1, 1, /*edge_comb=*/ 0);
39 if (igraph_ecount(&g) != 1) {
40 return 1;
41 }
42 igraph_destroy(&g);
43
44 /* Loop edges*/
45
46 igraph_small(&g, 0, IGRAPH_DIRECTED, 0, 0, 1, 1, 2, 2, 1, 2, -1);
47 igraph_simplify(&g, 1, 1, /*edge_comb=*/ 0);
48 igraph_write_graph_edgelist(&g, stdout);
49 igraph_destroy(&g);
50
51 igraph_small(&g, 0, IGRAPH_UNDIRECTED, 0, 0, 1, 1, 2, 2, 1, 2, -1);
52 igraph_simplify(&g, 1, 1, /*edge_comb=*/ 0);
53 igraph_write_graph_edgelist(&g, stdout);
54 igraph_destroy(&g);
55
56 /* Loop & multiple edges */
57
58 igraph_small(&g, 0, IGRAPH_DIRECTED, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, -1);
59 igraph_simplify(&g, 1 /* multiple */, 0 /* loop */, /*edge_comb=*/ 0);
60 igraph_write_graph_edgelist(&g, stdout);
61 igraph_destroy(&g);
62
63 igraph_small(&g, 0, IGRAPH_UNDIRECTED, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, -1);
64 igraph_simplify(&g, 1 /* multiple */, 0 /* loop */, /*edge_comb=*/ 0);
65 igraph_write_graph_edgelist(&g, stdout);
66 igraph_destroy(&g);
67
68 igraph_small(&g, 0, IGRAPH_DIRECTED, 2, 2, 2, 2, 2, 2, 3, 2, -1);
69 igraph_simplify(&g, 0 /* multiple */, 1 /* loop */, /*edge_comb=*/ 0);
70 igraph_write_graph_edgelist(&g, stdout);
71 igraph_destroy(&g);
72
73 igraph_small(&g, 0, IGRAPH_UNDIRECTED, 3, 3, 3, 3, 3, 4, -1);
74 igraph_simplify(&g, 0 /* multiple */, 1 /* loop */, /*edge_comb=*/ 0);
75 igraph_write_graph_edgelist(&g, stdout);
76 igraph_destroy(&g);
77
78 igraph_small(&g, 0, IGRAPH_DIRECTED, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, -1);
79 igraph_simplify(&g, 1, 1, /*edge_comb=*/ 0);
80 igraph_write_graph_edgelist(&g, stdout);
81 igraph_destroy(&g);
82
83 igraph_small(&g, 0, IGRAPH_UNDIRECTED,
84 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 3, 3, 2, 3, 2, 3, 2, -1);
85 igraph_simplify(&g, 1, 1, /*edge_comb=*/ 0);
86 if (igraph_ecount(&g) != 1) {
87 return 2;
88 }
89 igraph_destroy(&g);
90
91 return 0;
92 }
93