Revision 33e5ad95 custompackages/graph-parser/src/script.sh

View differences:

custompackages/graph-parser/src/script.sh
1 1
## TUTORIAL:
2 2
## The script take 2 command-line arguments:
3
## $1: input filepath
3
## $1: input folder
4 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)
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 7

  
8
## If no argument is supplied, then the default is "./script.sh true true"
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
9 11

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

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

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

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

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

  
45 50
make
46 51

  
47 52
## Create output directories if they are not existed
......
55 60
done
56 61

  
57 62
## Running the script
58
./graph-parser $filepath $input_type $WEIGHTED_GRAPH $TARGETS_INCLUSION
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

  
59 69

  
60 70
## Plotting the results
61 71
if [ $WEIGHTED_GRAPH="true" ]
......
67 77
    SUFFIX="unweighted";
68 78
fi
69 79

  
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[@]}"
80
for file in `ls ../output/ | grep out`;
76 81
do
77
    option="FILENAME='"$i"_"$SUFFIX"'; SUFFIX='$SUFFIX'";
82
    filename=${file%.*}
83
    option="FILENAME='$filename'; SUFFIX='$SUFFIX'";
78 84
    gnuplot -e "$option" plot_BC_comparison.gp
79
done
85
done

Also available in: Unified diff