4
Copyright (C) 2007 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
26
int print_vector(const igraph_vector_t *v) {
27
long int i, size=igraph_vector_size(v);
28
for (i=0; i<size; i++) {
29
printf("%g ", (double) VECTOR(*v)[i]);
37
igraph_vector_t weights, partition, partition2, cut;
38
igraph_integer_t value;
41
igraph_small(&g, 0, IGRAPH_UNDIRECTED,
42
0,1, 0,4, 1,2, 1,4, 1,5, 2,3, 2,6, 3,6, 3,7, 4,5, 5,6, 6,7,
45
igraph_vector_init_int_end(&weights, -1, 2,3,3,2,2, 4,2,2,2,3, 1,3, -1);
47
igraph_vector_init(&partition, 0);
48
igraph_vector_init(&partition2, 0);
49
igraph_vector_init(&cut, 0);
51
igraph_mincut(&g, &value, &partition, &partition2, &cut, &weights);
53
printf("mincut value: %g\n", (double) value);
55
printf("first partition: ");
56
igraph_vector_sort(&partition);
57
print_vector(&partition);
58
printf("second partition: ");
59
igraph_vector_sort(&partition2);
60
print_vector(&partition2);
61
printf("edges in the cut: ");
62
for (i=0; i<igraph_vector_size(&cut); i++) {
63
igraph_integer_t from, to;
64
igraph_edge(&g, VECTOR(cut)[i], &from, &to);
66
igraph_integer_t tmp=from;
70
printf("%li-%li ", (long int)from, (long int)to);
74
igraph_vector_destroy(&cut);
75
igraph_vector_destroy(&partition2);
76
igraph_vector_destroy(&partition);
77
igraph_vector_destroy(&weights);