1 /*
2 IGraph library.
3 Copyright (C) 2021 The igraph development team <igraph@igraph.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19
20 #include <igraph.h>
21
22 #include "test_utilities.inc"
23
main()24 int main() {
25
26 igraph_t g;
27 igraph_vector_t ecc;
28
29 igraph_vector_init(&ecc, 0);
30
31 printf("Null graph:\n");
32 igraph_empty(&g, 0, IGRAPH_UNDIRECTED);
33 igraph_eccentricity(&g, &ecc, igraph_vss_all(), IGRAPH_OUT);
34 print_vector(&ecc);
35 igraph_destroy(&g);
36
37 printf("\nSingleton graph:\n");
38 igraph_empty(&g, 1, IGRAPH_UNDIRECTED);
39 igraph_eccentricity(&g, &ecc, igraph_vss_all(), IGRAPH_OUT);
40 print_vector(&ecc);
41 igraph_destroy(&g);
42
43 printf("\nPath with isolated vertex:\n");
44 igraph_small(&g, 3, IGRAPH_UNDIRECTED,
45 0,2,
46 -1);
47 igraph_eccentricity(&g, &ecc, igraph_vss_all(), IGRAPH_OUT);
48 print_vector(&ecc);
49 igraph_destroy(&g);
50
51 printf("\nUndirected path graph:\n");
52 igraph_ring(&g, 5, IGRAPH_UNDIRECTED, /* mutual */ 0, /* circular */ 0);
53 igraph_eccentricity(&g, &ecc, igraph_vss_all(), IGRAPH_OUT);
54 print_vector(&ecc);
55 igraph_destroy(&g);
56
57 printf("\nDirected path graph:\n");
58 igraph_ring(&g, 5, IGRAPH_DIRECTED, /* mutual */ 0, /* circular */ 0);
59 igraph_eccentricity(&g, &ecc, igraph_vss_all(), IGRAPH_OUT);
60 print_vector(&ecc);
61 igraph_destroy(&g);
62
63 printf("\nUndirected star:\n");
64 igraph_star(&g, 10, IGRAPH_STAR_UNDIRECTED, 0);
65 igraph_eccentricity(&g, &ecc, igraph_vss_all(), IGRAPH_OUT);
66 print_vector(&ecc);
67 igraph_destroy(&g);
68
69 printf("\nOut-star:\n");
70 igraph_star(&g, 10, IGRAPH_STAR_OUT, 0);
71 igraph_eccentricity(&g, &ecc, igraph_vss_all(), IGRAPH_ALL);
72 print_vector(&ecc);
73 igraph_destroy(&g);
74
75 printf("\nIn-star:\n");
76 igraph_star(&g, 10, IGRAPH_STAR_OUT, 0);
77 igraph_eccentricity(&g, &ecc, igraph_vss_all(), IGRAPH_OUT);
78 print_vector(&ecc);
79 igraph_destroy(&g);
80
81 igraph_vector_destroy(&ecc);
82
83 VERIFY_FINALLY_STACK();
84
85 return 0;
86 }
87