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 igraph_strvector_t names;
30
31 igraph_set_attribute_table(&igraph_cattribute_table);
32
33 /* save a simple ring graph */
34 igraph_ring(&g, 10, IGRAPH_DIRECTED, 0 /* mutual */, 1 /* circular */);
35 igraph_write_graph_pajek(&g, stdout);
36
37 /* add some vertex attributes */
38 igraph_strvector_init(&names, 0);
39 igraph_strvector_add(&names, "A");
40 igraph_strvector_add(&names, "B");
41 igraph_strvector_add(&names, "C");
42 igraph_strvector_add(&names, "D");
43 igraph_strvector_add(&names, "E");
44 igraph_strvector_add(&names, "F");
45 igraph_strvector_add(&names, "G");
46 igraph_strvector_add(&names, "H");
47 igraph_strvector_add(&names, "I");
48 igraph_strvector_add(&names, "J");
49 SETVASV(&g, "id", &names);
50 igraph_strvector_destroy(&names);
51
52 /* save the graph with vertex names */
53 igraph_write_graph_pajek(&g, stdout);
54
55 igraph_strvector_init(&names, 0);
56 igraph_strvector_add(&names, "square");
57 igraph_strvector_add(&names, "square");
58 igraph_strvector_add(&names, "square");
59 igraph_strvector_add(&names, "square");
60 igraph_strvector_add(&names, "escaping spaces");
61 igraph_strvector_add(&names, "square");
62 igraph_strvector_add(&names, "square");
63 igraph_strvector_add(&names, "escaping \\backslashes\\");
64 igraph_strvector_add(&names, "square");
65 igraph_strvector_add(&names, "escaping \"quotes\"");
66 SETVASV(&g, "shape", &names);
67 igraph_strvector_destroy(&names);
68
69 /* save the graph with escaped shapes */
70 igraph_write_graph_pajek(&g, stdout);
71
72 /* destroy the graph */
73 igraph_destroy(&g);
74 return 0;
75 }
76