Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (2.11 KB)

1
## TUTORIAL:
2
## The script take 2 command-line arguments:
3
## $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
## $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
## $2: 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 true true"
9

    
10
#########
11
## YOU CAN MODIFY THIS PART
12
#########
13

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

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

    
41
#########
42
## TRY TO AVOID MODIFYING ANYTHING BELOW THIS LINE
43
#########
44
## Compile the source code
45
make
46

    
47
## 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

    
57
## Running the script
58
./graph-parser $filepath $input_type $WEIGHTED_GRAPH $TARGETS_INCLUSION
59

    
60
## Plotting the results
61
if [ $WEIGHTED_GRAPH="true" ]
62
then
63
    echo "weighted suffix"
64
    SUFFIX="weighted"; # the suffix used in the filename
65
else
66
    echo "unweighted suffix"
67
    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