Revision 6575aa2e 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
4
## $2: the type of input file, whether it's *.edges or *.json. Filetype is encoded by integer number 1, 2, 3
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
4
## $2: specify whether to include targets when calculating betweenness centrality (for the Brandes BC)
6
## $2: specify whether to include targets (and only targets, not sources) when calculating betweenness centrality (for the Brandes BC)
5 7

  
6 8
## If no argument is supplied, then the default is "./script.sh true true"
7 9

  
8 10
#########
9 11
## YOU CAN MODIFY THIS PART
10 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

  
11 26
# Change the variables to run the Betweenness Centrality for weighted or unweighted graph.
12
if [ -z "$1" ] # No argument supplied
27
if [ -z "$3" ] # No argument supplied
13 28
then
14 29
    WEIGHTED_GRAPH="true"; # 2 possible values: [true | false]
15 30
else
16
    WEIGHTED_GRAPH="$1";
31
    WEIGHTED_GRAPH="$3";
17 32
fi
18 33

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

  
26 41
#########
......
39 54
    fi
40 55
done
41 56

  
42
filepath="../input/simple.edges"
43
input_type=1
44 57
## Running the script
45 58
./graph-parser $filepath $input_type $WEIGHTED_GRAPH $TARGETS_INCLUSION
46 59

  
47 60
## Plotting the results
48
if [ $WEIGHTED_GRAPH = "true" ]
61
if [ $WEIGHTED_GRAPH="true" ]
49 62
then
63
    echo "weighted suffix"
50 64
    SUFFIX="weighted"; # the suffix used in the filename
51 65
else
66
    echo "unweighted suffix"
52 67
    SUFFIX="unweighted";
53 68
fi
54 69

  

Also available in: Unified diff