Skip to content

Commit

Permalink
Quit graphpass on graph with > 500,000 edges in the graph; resolves #60
Browse files Browse the repository at this point in the history
… (#61)

* Add optional max-nodes and max-edges flags.
* Some minor clean up of flags for alpha order.
  • Loading branch information
greebie authored and ruebot committed Sep 10, 2018
1 parent b1f8eec commit bbde012
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
8 changes: 7 additions & 1 deletion src/headers/graphpass.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ char* ug_methods; /**< METHODS to filter */
char* ug_OUTPUT; /**< Folder to output new graphs */
char* OUTPATH; /**< Path to output folder (DIRECTORY + OUTPUT) */
igraph_integer_t NODESIZE; /**< Number of Nodes in original graph */
igraph_integer_t EDGESIZE; /**< Number of Edges in original graph */
float ug_percent; /**< Filtering percentage 0.0 by default */
long ug_maxnodes; /**< user-defined max nodes for processing, default MAX_NODES */
long ug_maxedges; /**< user-defined maxiumum edges for processing default MAX_EDGES */
bool ug_report; /**< Include a report? */
bool ug_gformat; /**< Graph format - true is "GEXF" false is "GRAPHML" */
bool ug_quickrun; /**< Lightweight visualization run */
Expand Down Expand Up @@ -77,7 +80,10 @@ igraph_vector_t WEIGHTED; /**< If greater than 0, conducts weighted analysis */
#define COLOR_BASE "WalkTrapModularity"
#define PAGERANK_DAMPING 0.85 /**< chance random walk will not restart */
#define LAYOUT_DEFAULT_CHAR 'f'
#define MAX_NODES 50000 /**< number of nodes in graph before shut down */
#define MAX_NODES 50000 /**< default number of nodes in graph before shut down */
#define MAX_EDGES 500000 /**< default number of edges in graph before shut down */
#define MAX_USER_EDGES 1000000000
#define MAX_USER_NODES 1000000000

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

Expand Down
33 changes: 22 additions & 11 deletions src/main/graphpass.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,26 @@ int main (int argc, char *argv[]) {
{
static struct option long_options[] =
{
/* These options don’t set a flag.
We distinguish them by their indices. */
{"verbose", no_argument, 0, 'v'},
{"no-save", no_argument, 0, 'n'},
{"report", no_argument, 0, 'r'},
/* These options have no required argument */
{"gexf", no_argument, 0, 'g'},
{"no-save", no_argument, 0, 'n'},
{"verbose", no_argument, 0, 'v'},
{"quick", no_argument, 0, 'q'},
{"weighted",no_argument, 0, 'w'},
{"report", no_argument, 0, 'r'},

/* These options require an argument */
{"dir", required_argument, 0, 'd'},
{"file", required_argument, 0, 'f'},
{"percent", required_argument, 0, 'p'},
{"methods", required_argument, 0, 'm'},
{"output", required_argument, 0, 'o'},
{"dir", required_argument, 0, 'd'},
{"percent", required_argument, 0, 'p'},
{"max-nodes", required_argument, 0, 'x'},
{"max-edges", required_argument, 0, 'y'},
{0, 0, 0, 0}
};
/* getopt_long stores the option index here. */
int option_index = 0;
c = getopt_long (argc, argv, "vnrgqwf:p:m:o:d",
c = getopt_long (argc, argv, "gnvqrd:f:m:o:p:x:y:",
long_options, &option_index);

/* Detect the end of the options. */
Expand Down Expand Up @@ -121,6 +123,12 @@ int main (int argc, char *argv[]) {
case 'w':
CALC_WEIGHTS = !CALC_WEIGHTS;
break;
case 'x':
ug_maxnodes = optarg ? (long)strtol(optarg, (char**)NULL, 10) : MAX_NODES;
break;
case 'y':
ug_maxedges = optarg ? (long)strtol(optarg, (char**)NULL, 10) : MAX_EDGES;
break;
case '?':
/* getopt_long already printed an error message. */
break;
Expand All @@ -139,6 +147,8 @@ int main (int argc, char *argv[]) {
}

/** set default values if not included in flags **/
ug_maxnodes = ug_maxnodes ? ug_maxnodes : MAX_NODES;
ug_maxedges = ug_maxedges ? ug_maxedges : MAX_EDGES;
ug_OUTPUT = ug_OUTPUT ? ug_OUTPUT : "OUT/";
ug_percent = ug_percent ? ug_percent : 0.00;
ug_methods = ug_methods ? ug_methods : "d";
Expand Down Expand Up @@ -176,8 +186,9 @@ int main (int argc, char *argv[]) {
}
load_graph(FILEPATH);
free(FILEPATH);
if (igraph_vcount(&g) > MAX_NODES) {
printf ("FAIL >>> Graphpass can only conduct analysis on graphs with fewer than %i nodes.\n", MAX_NODES);
if (igraph_vcount(&g) > ug_maxnodes || igraph_ecount(&g) > ug_maxedges){
printf ("FAIL >>> Graphpass can only conduct analysis on graphs with \
fewer than %li nodes and %li edges.\n", ug_maxnodes, ug_maxedges);
printf ("FAIL >>> Exiting...\n");
exit(EXIT_FAILURE);
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ extern int load_graph (char* filename) {
}
igraph_read_graph_graphml(&g, fp, 0);
NODESIZE = igraph_vcount(&g);
EDGESIZE = igraph_ecount(&g);
if (ug_verbose) {
printf("Successfully ingested graph with %li nodes.\n", (long int)NODESIZE);
printf("Successfully ingested graph with %li nodes and %li edges.\n"
, (long int)NODESIZE, (long int)EDGESIZE);
}
fclose(fp);
return (0);
Expand Down Expand Up @@ -108,4 +110,3 @@ extern int write_graph(igraph_t *graph, char *attr) {
}
return 0;
}

0 comments on commit bbde012

Please sign in to comment.