1 /* -*- mode: C -*- */
2 /*
3 IGraph library.
4 Copyright (C) 2010-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 #include <stdio.h>
26
27 #include "test_utilities.inc"
28
main()29 int main() {
30 igraph_t g, sub;
31 igraph_vector_t map, invmap;
32 igraph_vector_t keep;
33 long int i;
34
35 igraph_small(&g, 9, IGRAPH_DIRECTED, 0, 1, 0, 2, 1, 3, 2, 3,
36 1, 4, 4, 2, 1, 5, 5, 2, 1, 6, 6, 2, 1, 7, 7, 2, 1, 8, 8, 2,
37 -1);
38 igraph_vector_init(&map, 0);
39 igraph_vector_init(&invmap, 0);
40 igraph_vector_init(&keep, igraph_vcount(&g));
41 for (i = 0; i < igraph_vector_size(&keep); i++) {
42 VECTOR(keep)[i] = i;
43 }
44
45 igraph_induced_subgraph_map(&g, &sub,
46 igraph_vss_vector(&keep),
47 IGRAPH_SUBGRAPH_COPY_AND_DELETE,
48 &map, &invmap);
49
50 printf("Map: ");
51 igraph_vector_print(&map);
52 printf("Inverse map: ");
53 igraph_vector_print(&invmap);
54 igraph_write_graph_edgelist(&sub, stdout);
55
56 igraph_vector_destroy(&keep);
57 igraph_vector_destroy(&map);
58 igraph_vector_destroy(&invmap);
59
60 igraph_destroy(&sub);
61 igraph_destroy(&g);
62
63 VERIFY_FINALLY_STACK();
64
65 return 0;
66 }
67