4
Copyright (C) 2006 Gabor Csardi <csardi@rmki.kfki.hu>
5
MTA RMKI, Konkoly-Thege Miklos st. 29-33, Budapest 1121, Hungary
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.
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.
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
29
igraph_vector_t tdist;
32
igraph_vector_bool_t bs;
35
/* Symmetric preference game */
36
igraph_vector_bool_init(&bs, 0);
38
igraph_vector_init_real(&tdist, 3, 1.0, 1.0, 1.0);
40
igraph_matrix_init(&pmat, 3, 3);
41
for (i=0; i<3; i++) MATRIX(pmat, i, i) = 0.2;
43
/* undirected, no loops */
44
IGRAPH_CHECK(igraph_preference_game(&g, 1000, 3, &tdist, &pmat, 0, 0, 0));
45
if (igraph_vcount(&g) != 1000) return 18;
46
if (igraph_is_directed(&g)) return 2;
47
igraph_is_connected(&g, &conn, IGRAPH_STRONG);
49
igraph_is_loop(&g, &bs, igraph_ess_all(IGRAPH_EDGEORDER_ID));
50
if (igraph_vector_bool_sum(&bs)) return 4;
51
igraph_is_multiple(&g, &bs, igraph_ess_all(IGRAPH_EDGEORDER_ID));
52
if (igraph_vector_bool_sum(&bs)) return 5;
55
for (i=0; i<2; i++) MATRIX(pmat, i, i+1) = 0.1;
57
/* directed, no loops */
58
IGRAPH_CHECK(igraph_preference_game(&g, 1000, 3, &tdist, &pmat, 0, 1, 0));
59
if (igraph_vcount(&g) != 1000) return 17;
60
if (!igraph_is_directed(&g)) return 6;
61
igraph_is_loop(&g, &bs, igraph_ess_all(IGRAPH_EDGEORDER_ID));
62
if (igraph_vector_bool_sum(&bs)) return 7;
63
igraph_is_multiple(&g, &bs, igraph_ess_all(IGRAPH_EDGEORDER_ID));
64
if (igraph_vector_bool_sum(&bs)) return 8;
67
/* undirected, loops */
68
for (i=0; i<3; i++) MATRIX(pmat, i, i) = 1.0;
69
IGRAPH_CHECK(igraph_preference_game(&g, 100, 3, &tdist, &pmat, 0, 0, 1));
70
if (igraph_vcount(&g) != 100) return 16;
71
if (igraph_ecount(&g) < 1395) return 20;
72
if (igraph_is_directed(&g)) return 9;
73
igraph_is_loop(&g, &bs, igraph_ess_all(IGRAPH_EDGEORDER_ID));
74
if (igraph_vector_bool_sum(&bs) == 0) return 10;
75
igraph_is_multiple(&g, &bs, igraph_ess_all(IGRAPH_EDGEORDER_ID));
76
if (igraph_vector_bool_sum(&bs)) return 11;
80
IGRAPH_CHECK(igraph_preference_game(&g, 100, 3, &tdist, &pmat, 0, 1, 1));
81
if (igraph_vcount(&g) != 100) return 15;
82
if (igraph_ecount(&g) < 2700) return 19;
83
if (!igraph_is_directed(&g)) return 12;
84
igraph_is_loop(&g, &bs, igraph_ess_all(IGRAPH_EDGEORDER_ID));
85
if (igraph_vector_bool_sum(&bs) == 0) return 13;
86
igraph_is_multiple(&g, &bs, igraph_ess_all(IGRAPH_EDGEORDER_ID));
87
if (igraph_vector_bool_sum(&bs)) return 14;
90
/* Asymmetric preference game */
92
/* directed, no loops */
93
igraph_matrix_resize(&pmat, 2, 2);
94
MATRIX(pmat, 0, 0) = 1; MATRIX(pmat, 0, 1) = 1;
95
MATRIX(pmat, 1, 0) = 1; MATRIX(pmat, 1, 1) = 1;
96
IGRAPH_CHECK(igraph_asymmetric_preference_game(&g, 100, 2, 0, &pmat, 0, 0, 0));
97
if (igraph_vcount(&g) != 100) return 21;
98
if (igraph_ecount(&g) != 9900) return 22;
99
if (!igraph_is_directed(&g)) return 23;
100
igraph_is_loop(&g, &bs, igraph_ess_all(IGRAPH_EDGEORDER_ID));
101
if (igraph_vector_bool_sum(&bs)) return 24;
102
igraph_is_multiple(&g, &bs, igraph_ess_all(IGRAPH_EDGEORDER_ID));
103
if (igraph_vector_bool_sum(&bs)) return 25;
106
/* directed, loops */
107
igraph_matrix_resize(&pmat, 2, 2);
108
MATRIX(pmat, 0, 0) = 1; MATRIX(pmat, 0, 1) = 1;
109
MATRIX(pmat, 1, 0) = 1; MATRIX(pmat, 1, 1) = 1;
110
IGRAPH_CHECK(igraph_asymmetric_preference_game(&g, 100, 2, 0, &pmat, 0, 0, 1));
111
if (igraph_vcount(&g) != 100) return 26;
112
if (igraph_ecount(&g) != 10000) return 27;
113
if (!igraph_is_directed(&g)) return 28;
114
igraph_is_loop(&g, &bs, igraph_ess_all(IGRAPH_EDGEORDER_ID));
115
if (igraph_vector_bool_sum(&bs) != 100) return 29;
116
igraph_is_multiple(&g, &bs, igraph_ess_all(IGRAPH_EDGEORDER_ID));
117
if (igraph_vector_bool_sum(&bs)) return 30;
120
igraph_vector_destroy(&tdist);
121
igraph_matrix_destroy(&pmat);
122
igraph_vector_bool_destroy(&bs);
124
assert(IGRAPH_FINALLY_STACK_EMPTY);