Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (2.12 KB)

1 d5b7a27f Quynh PX Nguyen
## TUTORIAL:
2
## The script take 2 command-line arguments:
3 33e5ad95 Quynh PX Nguyen
## $1: input folder
4 6575aa2e Quynh PX Nguyen
## $2: the type of input file, whether it's *.edges or *.json. Filetype is encoded by integer number 1, 2, 3
5 33e5ad95 Quynh PX Nguyen
## $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 d5b7a27f Quynh PX Nguyen
8 33e5ad95 Quynh PX Nguyen
## 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 d5b7a27f Quynh PX Nguyen
12
#########
13
## YOU CAN MODIFY THIS PART
14
#########
15 6575aa2e Quynh PX Nguyen
16
if [ -z "$1" ]; then
17 33e5ad95 Quynh PX Nguyen
    inputdir="../input";
18 6575aa2e Quynh PX Nguyen
else
19 33e5ad95 Quynh PX Nguyen
    inputdir="$1";
20 6575aa2e Quynh PX Nguyen
fi
21
22
if [ -z "$2" ]; then
23
    input_type=1;
24
else
25
    input_type="$2";
26
fi
27
28 d5b7a27f Quynh PX Nguyen
# Change the variables to run the Betweenness Centrality for weighted or unweighted graph.
29 6575aa2e Quynh PX Nguyen
if [ -z "$3" ] # No argument supplied
30 d5b7a27f Quynh PX Nguyen
then
31 33e5ad95 Quynh PX Nguyen
    WEIGHTED_GRAPH="false"; # 2 possible values: [true | false]
32 d5b7a27f Quynh PX Nguyen
else
33 6575aa2e Quynh PX Nguyen
    WEIGHTED_GRAPH="$3";
34 d5b7a27f Quynh PX Nguyen
fi
35
36 6575aa2e Quynh PX Nguyen
if [ -z "$4" ] # No argument supplied
37 d5b7a27f Quynh PX Nguyen
then
38 33e5ad95 Quynh PX Nguyen
   ENDPOINTS_INCLUSION="true"; # 2 possible values: [true | false]
39 d5b7a27f Quynh PX Nguyen
else
40 33e5ad95 Quynh PX Nguyen
    ENDPOINTS_INCLUSION="$4";
41 d5b7a27f Quynh PX Nguyen
fi
42
43
#########
44
## TRY TO AVOID MODIFYING ANYTHING BELOW THIS LINE
45
#########
46 f9e3a1f0 Quynh PX Nguyen
## Compile the source code
47 33e5ad95 Quynh PX Nguyen
# rm -f bi_connected_components.o
48
# rm -f sub_component.o
49
50 af008982 Quynh PX Nguyen
make
51 d5b7a27f Quynh PX Nguyen
52 f9e3a1f0 Quynh PX Nguyen
## 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 d5b7a27f Quynh PX Nguyen
62
## Running the script
63 33e5ad95 Quynh PX Nguyen
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 d5b7a27f Quynh PX Nguyen
70
## Plotting the results
71 6575aa2e Quynh PX Nguyen
if [ $WEIGHTED_GRAPH="true" ]
72 d5b7a27f Quynh PX Nguyen
then
73 6575aa2e Quynh PX Nguyen
    echo "weighted suffix"
74 d5b7a27f Quynh PX Nguyen
    SUFFIX="weighted"; # the suffix used in the filename
75
else
76 6575aa2e Quynh PX Nguyen
    echo "unweighted suffix"
77 d5b7a27f Quynh PX Nguyen
    SUFFIX="unweighted";
78
fi
79
80 33e5ad95 Quynh PX Nguyen
for file in `ls ../output/ | grep out`;
81 d5b7a27f Quynh PX Nguyen
do
82 33e5ad95 Quynh PX Nguyen
    filename=${file%.*}
83
    option="FILENAME='$filename'; SUFFIX='$SUFFIX'";
84 d5b7a27f Quynh PX Nguyen
    gnuplot -e "$option" plot_BC_comparison.gp
85 33e5ad95 Quynh PX Nguyen
done