Statistics
| Branch: | Revision:

root / custompackages / graph-parser / src / script.sh @ 6575aa2e

History | View | Annotate | Download (2.11 KB)

1 d5b7a27f Quynh PX Nguyen
## TUTORIAL:
2
## The script take 2 command-line arguments:
3 6575aa2e Quynh PX Nguyen
## $1: input filepath
4
## $2: the type of input file, whether it's *.edges or *.json. Filetype is encoded by integer number 1, 2, 3
5 d5b7a27f Quynh PX Nguyen
## $1: 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 6575aa2e Quynh PX Nguyen
## $2: specify whether to include targets (and only targets, not sources) when calculating betweenness centrality (for the Brandes BC)
7 d5b7a27f Quynh PX Nguyen
8
## If no argument is supplied, then the default is "./script.sh true true"
9
10
#########
11
## YOU CAN MODIFY THIS PART
12
#########
13 6575aa2e Quynh PX Nguyen
14
if [ -z "$1" ]; then
15
    filepath="../input/simple.edges";
16
else
17
    filepath="$1";
18
fi
19
20
if [ -z "$2" ]; then
21
    input_type=1;
22
else
23
    input_type="$2";
24
fi
25
26 d5b7a27f Quynh PX Nguyen
# Change the variables to run the Betweenness Centrality for weighted or unweighted graph.
27 6575aa2e Quynh PX Nguyen
if [ -z "$3" ] # No argument supplied
28 d5b7a27f Quynh PX Nguyen
then
29
    WEIGHTED_GRAPH="true"; # 2 possible values: [true | false]
30
else
31 6575aa2e Quynh PX Nguyen
    WEIGHTED_GRAPH="$3";
32 d5b7a27f Quynh PX Nguyen
fi
33
34 6575aa2e Quynh PX Nguyen
if [ -z "$4" ] # No argument supplied
35 d5b7a27f Quynh PX Nguyen
then
36
   TARGETS_INCLUSION="true"; # 2 possible values: [true | false]
37
else
38 6575aa2e Quynh PX Nguyen
    TARGETS_INCLUSION="$4";
39 d5b7a27f Quynh PX Nguyen
fi
40
41
#########
42
## TRY TO AVOID MODIFYING ANYTHING BELOW THIS LINE
43
#########
44 f9e3a1f0 Quynh PX Nguyen
## Compile the source code
45 af008982 Quynh PX Nguyen
make
46 d5b7a27f Quynh PX Nguyen
47 f9e3a1f0 Quynh PX Nguyen
## Create output directories if they are not existed
48
declare -a dir_arr=("../output" "../output/visualization")
49
for i in "${dir_arr[@]}"
50
do
51
    echo $i;
52
    if [ ! -d $i ]; then
53
        mkdir $i;
54
    fi
55
done
56 d5b7a27f Quynh PX Nguyen
57
## Running the script
58 f9e3a1f0 Quynh PX Nguyen
./graph-parser $filepath $input_type $WEIGHTED_GRAPH $TARGETS_INCLUSION
59 d5b7a27f Quynh PX Nguyen
60
## Plotting the results
61 6575aa2e Quynh PX Nguyen
if [ $WEIGHTED_GRAPH="true" ]
62 d5b7a27f Quynh PX Nguyen
then
63 6575aa2e Quynh PX Nguyen
    echo "weighted suffix"
64 d5b7a27f Quynh PX Nguyen
    SUFFIX="weighted"; # the suffix used in the filename
65
else
66 6575aa2e Quynh PX Nguyen
    echo "unweighted suffix"
67 d5b7a27f Quynh PX Nguyen
    SUFFIX="unweighted";
68
fi
69
70
## declare an array variables
71
declare -a arr=("simple" "ninux_unweighted_connected" "ninux_30_1" "jsoninfo_topo" "olsr-netjson")
72
73
# loop through the array and format the option for gnuplot
74
# gnuplot -e "FILENAME='simple'; SUFFIX='$SUFFIX'" plot_BC_comparison.gp
75
for i in "${arr[@]}"
76
do
77
    option="FILENAME='"$i"_"$SUFFIX"'; SUFFIX='$SUFFIX'";
78
    gnuplot -e "$option" plot_BC_comparison.gp
79
done