Statistics
| Branch: | Revision:

root / custompackages / graph-parser / src / script.sh @ 33e5ad95

History | View | Annotate | Download (2.12 KB)

1
## TUTORIAL:
2
## The script take 2 command-line arguments:
3
## $1: input folder
4
## $2: the type of input file, whether it's *.edges or *.json. Filetype is encoded by integer number 1, 2, 3
5
## $3: specify whether to calculate betweenness centrality as an unweighted graph (false) or weighted graph (true). This argument is for both Heuristic BC and Brandes BC
6
## $4: specify whether to include targets (and only targets, not sources) when calculating betweenness centrality (for the Brandes BC)
7

    
8
## If no argument is supplied, then the default is "./script.sh ../input/simple.edges 1 true true"
9
## If no argument is supplied, then the default is
10
        # ./script.sh ../input 1 false true
11

    
12
#########
13
## YOU CAN MODIFY THIS PART
14
#########
15

    
16
if [ -z "$1" ]; then
17
    inputdir="../input";
18
else
19
    inputdir="$1";
20
fi
21

    
22
if [ -z "$2" ]; then
23
    input_type=1;
24
else
25
    input_type="$2";
26
fi
27

    
28
# Change the variables to run the Betweenness Centrality for weighted or unweighted graph.
29
if [ -z "$3" ] # No argument supplied
30
then
31
    WEIGHTED_GRAPH="false"; # 2 possible values: [true | false]
32
else
33
    WEIGHTED_GRAPH="$3";
34
fi
35

    
36
if [ -z "$4" ] # No argument supplied
37
then
38
   ENDPOINTS_INCLUSION="true"; # 2 possible values: [true | false]
39
else
40
    ENDPOINTS_INCLUSION="$4";
41
fi
42

    
43
#########
44
## TRY TO AVOID MODIFYING ANYTHING BELOW THIS LINE
45
#########
46
## Compile the source code
47
# rm -f bi_connected_components.o
48
# rm -f sub_component.o
49

    
50
make
51

    
52
## Create output directories if they are not existed
53
declare -a dir_arr=("../output" "../output/visualization")
54
for i in "${dir_arr[@]}"
55
do
56
    echo $i;
57
    if [ ! -d $i ]; then
58
        mkdir $i;
59
    fi
60
done
61

    
62
## Running the script
63
for file in `ls $inputdir | grep edges`;
64
do
65

    
66
    ./graph-parser ../input/$file $input_type $WEIGHTED_GRAPH $ENDPOINTS_INCLUSION
67
done
68

    
69

    
70
## Plotting the results
71
if [ $WEIGHTED_GRAPH="true" ]
72
then
73
    echo "weighted suffix"
74
    SUFFIX="weighted"; # the suffix used in the filename
75
else
76
    echo "unweighted suffix"
77
    SUFFIX="unweighted";
78
fi
79

    
80
for file in `ls ../output/ | grep out`;
81
do
82
    filename=${file%.*}
83
    option="FILENAME='$filename'; SUFFIX='$SUFFIX'";
84
    gnuplot -e "$option" plot_BC_comparison.gp
85
done