Skip to content

Commit bbde012

Browse files
greebieruebot
authored andcommitted
Quit graphpass on graph with > 500,000 edges in the graph; resolves #60 (#61)
* Add optional max-nodes and max-edges flags. * Some minor clean up of flags for alpha order.
1 parent b1f8eec commit bbde012

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

src/headers/graphpass.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ char* ug_methods; /**< METHODS to filter */
4242
char* ug_OUTPUT; /**< Folder to output new graphs */
4343
char* OUTPATH; /**< Path to output folder (DIRECTORY + OUTPUT) */
4444
igraph_integer_t NODESIZE; /**< Number of Nodes in original graph */
45+
igraph_integer_t EDGESIZE; /**< Number of Edges in original graph */
4546
float ug_percent; /**< Filtering percentage 0.0 by default */
47+
long ug_maxnodes; /**< user-defined max nodes for processing, default MAX_NODES */
48+
long ug_maxedges; /**< user-defined maxiumum edges for processing default MAX_EDGES */
4649
bool ug_report; /**< Include a report? */
4750
bool ug_gformat; /**< Graph format - true is "GEXF" false is "GRAPHML" */
4851
bool ug_quickrun; /**< Lightweight visualization run */
@@ -77,7 +80,10 @@ igraph_vector_t WEIGHTED; /**< If greater than 0, conducts weighted analysis */
7780
#define COLOR_BASE "WalkTrapModularity"
7881
#define PAGERANK_DAMPING 0.85 /**< chance random walk will not restart */
7982
#define LAYOUT_DEFAULT_CHAR 'f'
80-
#define MAX_NODES 50000 /**< number of nodes in graph before shut down */
83+
#define MAX_NODES 50000 /**< default number of nodes in graph before shut down */
84+
#define MAX_EDGES 500000 /**< default number of edges in graph before shut down */
85+
#define MAX_USER_EDGES 1000000000
86+
#define MAX_USER_NODES 1000000000
8187

8288
#define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
8389

src/main/graphpass.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/main/io.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ extern int load_graph (char* filename) {
5252
}
5353
igraph_read_graph_graphml(&g, fp, 0);
5454
NODESIZE = igraph_vcount(&g);
55+
EDGESIZE = igraph_ecount(&g);
5556
if (ug_verbose) {
56-
printf("Successfully ingested graph with %li nodes.\n", (long int)NODESIZE);
57+
printf("Successfully ingested graph with %li nodes and %li edges.\n"
58+
, (long int)NODESIZE, (long int)EDGESIZE);
5759
}
5860
fclose(fp);
5961
return (0);
@@ -108,4 +110,3 @@ extern int write_graph(igraph_t *graph, char *attr) {
108110
}
109111
return 0;
110112
}
111-

0 commit comments

Comments
 (0)