-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain_reliability_links_mb_gibbs.c
84 lines (75 loc) · 2.12 KB
/
main_reliability_links_mb_gibbs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
main_reliability_links_mb_gibbs.c
*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <gsl/gsl_rng.h>
#include "tools.h"
#include "graph.h"
#include "multiblock.h"
int
main(int argc, char **argv)
{
char *netF;
FILE *infile=NULL;
FILE *outfileAND=NULL, *outfileOR=NULL;
struct node_gra *net=NULL;
gsl_rng *rand_gen;
double **newA_AND;
struct node_gra *p1, *p2;
long int seed;
char outFileNameOR[200], outFileNameAND[200];
/*
---------------------------------------------------------------------------
Command line parameters
---------------------------------------------------------------------------
*/
if (argc < 2) {
printf("\nUse: links net_file seed\n\n");
return;
}
netF = argv[1];
seed = atoi(argv[2]);
rand_gen = gsl_rng_alloc(gsl_rng_mt19937);
gsl_rng_set(rand_gen, seed);
/*
---------------------------------------------------------------------------
Build the network
---------------------------------------------------------------------------
*/
infile = fopen(netF, "r");
net = FBuildNetwork(infile, 0, 0, 0, 1);
fclose(infile);
/*
---------------------------------------------------------------------------
Get link reliabilities
---------------------------------------------------------------------------
*/
newA_AND = GibbsLinkScoreMB(net, 0.0, 10000, rand_gen, 'q');
/*
---------------------------------------------------------------------------
Output
---------------------------------------------------------------------------
*/
strcpy(outFileNameAND, netF);
strcat(outFileNameAND, ".AND_scores");
outfileAND = fopen(outFileNameAND, "w");
p1 = net;
while ((p1 = p1->next) != NULL) {
p2 = p1;
while ((p2 = p2->next) != NULL) {
fprintf(outfileAND,
"%g %s %s\n", newA_AND[p1->num][p2->num], p1->label, p2->label);
}
}
fclose(outfileAND);
/*
---------------------------------------------------------------------------
Finish
---------------------------------------------------------------------------
*/
RemoveGraph(net);
gsl_rng_free(rand_gen);
return 0;
}