@@ -58,24 +58,26 @@ int main (int argc, char *argv[]) {
5858 {
5959 static struct option long_options [] =
6060 {
61- /* These options don’t set a flag.
62- We distinguish them by their indices. */
63- {"verbose" , no_argument , 0 , 'v' },
64- {"no-save" , no_argument , 0 , 'n' },
65- {"report" , no_argument , 0 , 'r' },
61+ /* These options have no required argument */
6662 {"gexf" , no_argument , 0 , 'g' },
63+ {"no-save" , no_argument , 0 , 'n' },
64+ {"verbose" , no_argument , 0 , 'v' },
6765 {"quick" , no_argument , 0 , 'q' },
68- {"weighted" ,no_argument , 0 , 'w' },
66+ {"report" , no_argument , 0 , 'r' },
67+
68+ /* These options require an argument */
69+ {"dir" , required_argument , 0 , 'd' },
6970 {"file" , required_argument , 0 , 'f' },
70- {"percent" , required_argument , 0 , 'p' },
7171 {"methods" , required_argument , 0 , 'm' },
7272 {"output" , required_argument , 0 , 'o' },
73- {"dir" , required_argument , 0 , 'd' },
73+ {"percent" , required_argument , 0 , 'p' },
74+ {"max-nodes" , required_argument , 0 , 'x' },
75+ {"max-edges" , required_argument , 0 , 'y' },
7476 {0 , 0 , 0 , 0 }
7577 };
7678 /* getopt_long stores the option index here. */
7779 int option_index = 0 ;
78- c = getopt_long (argc , argv , "vnrgqwf:p :m:o:d " ,
80+ c = getopt_long (argc , argv , "gnvqrd:f :m:o:p:x:y: " ,
7981 long_options , & option_index );
8082
8183 /* Detect the end of the options. */
@@ -121,6 +123,12 @@ int main (int argc, char *argv[]) {
121123 case 'w' :
122124 CALC_WEIGHTS = !CALC_WEIGHTS ;
123125 break ;
126+ case 'x' :
127+ ug_maxnodes = optarg ? (long )strtol (optarg , (char * * )NULL , 10 ) : MAX_NODES ;
128+ break ;
129+ case 'y' :
130+ ug_maxedges = optarg ? (long )strtol (optarg , (char * * )NULL , 10 ) : MAX_EDGES ;
131+ break ;
124132 case '?' :
125133 /* getopt_long already printed an error message. */
126134 break ;
@@ -139,6 +147,8 @@ int main (int argc, char *argv[]) {
139147 }
140148
141149 /** set default values if not included in flags **/
150+ ug_maxnodes = ug_maxnodes ? ug_maxnodes : MAX_NODES ;
151+ ug_maxedges = ug_maxedges ? ug_maxedges : MAX_EDGES ;
142152 ug_OUTPUT = ug_OUTPUT ? ug_OUTPUT : "OUT/" ;
143153 ug_percent = ug_percent ? ug_percent : 0.00 ;
144154 ug_methods = ug_methods ? ug_methods : "d" ;
@@ -176,8 +186,9 @@ int main (int argc, char *argv[]) {
176186 }
177187 load_graph (FILEPATH );
178188 free (FILEPATH );
179- if (igraph_vcount (& g ) > MAX_NODES ) {
180- printf ("FAIL >>> Graphpass can only conduct analysis on graphs with fewer than %i nodes.\n" , MAX_NODES );
189+ if (igraph_vcount (& g ) > ug_maxnodes || igraph_ecount (& g ) > ug_maxedges ){
190+ printf ("FAIL >>> Graphpass can only conduct analysis on graphs with \
191+ fewer than %li nodes and %li edges.\n" , ug_maxnodes , ug_maxedges );
181192 printf ("FAIL >>> Exiting...\n" );
182193 exit (EXIT_FAILURE );
183194 }
0 commit comments