Permalink
Browse files

Kill Graphpass on graphs with greater than 40,000 nodes (Issue #22) (#23

)

* Upgrade gexf output to 1.3.
* Kill graphpass on nodes > MAX_NODES (currently set to 40,000).
* Review request for using CONSTANT instead of "40k"
* Create verbose mode (-v or --verbose).
* Set MAX_NODES to 50000.
* "Less" should be "Fewer" in error message.
  • Loading branch information...
greebie authored and ianmilligan1 committed Jun 12, 2018
1 parent 993c231 commit d17b57c8d8eb7c7927fb7b5b74c748b293efba35
Showing with 64 additions and 42 deletions.
  1. +4 −1 headers/graphpass.h
  2. +0 −2 src/analyze.c
  3. +12 −9 src/filter.c
  4. +7 −7 src/gexf.c
  5. +23 −20 src/graphpass.c
  6. +6 −3 src/io.c
  7. +12 −0 src/quickrun.c
View
@@ -30,6 +30,7 @@
#include <getopt.h>
typedef enum { false, true } bool;
typedef enum { FAIL, WARN, COMM } broadcast;
igraph_t g;
igraph_attribute_table_t att;
@@ -44,6 +45,7 @@ bool ug_report; /**< Include a report? */
bool ug_gformat; /**< Graph format - true is "GEXF" false is "GRAPHML" */
bool ug_quickrun; /**< Lightweight visualization run */
bool ug_save; /**< If false, does not save graphs at all (for reports) */
bool ug_verbose; //**< Verbose mode (default off). */
bool CALC_WEIGHTS;
igraph_vector_t WEIGHTED; /**< If greater than 0, conducts weighted analysis */
@@ -65,14 +67,15 @@ igraph_vector_t WEIGHTED; /**< If greater than 0, conducts weighted analysis */
#define VIZ_SET_LARGE "viz_large.h"
#define VIZ_SET_SMALL "vis_small.h"
/* Required External libraries */
/* Default Settings */
#define MAX_METHODS 9
#define ALL_METHODS "abdehiopr"
#define SIZE_DEFAULT "Degree"
#define SIZE_DEFAULT_CHAR 'd'
#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 NELEMS(x) (sizeof(x) / sizeof((x)[0]))
View
@@ -207,7 +207,6 @@ int paired_t_stat (igraph_vector_t *v1, igraph_vector_t *v2, igraph_real_t *pv,
igraph_real_t pvalue;
for (long int i=0; i<igraph_vector_size(v2); i++) {
//printf("diff %f", igraph_vector_e(v1,i) - igraph_vector_e(v2,i));
VECTOR(diff)[i] = igraph_vector_e(v1,i) - igraph_vector_e(v2,i);
}
*pv = t_test_vector(&diff, igraph_vector_size(&diff)-1);
@@ -428,7 +427,6 @@ int produceRank(igraph_vector_t *source, igraph_vector_t *v) {
} else {
VECTOR(rank_vals)[i] = i+1;
}
//printf("I : %li, RANKVALS: %f", i, VECTOR(rank_vals)[i]);
}
for (long int i=0; i < source_size; i++) {
for (long int j=0; j < source_size; j++) {
View
@@ -168,7 +168,6 @@ int create_filtered_graph(igraph_t *graph, double cutoff, int cutsize, char* att
VANV(&g2, "Outdegree", &odeg);
// print size here.
produceRank(&size, &rank);
printf("finishProduce Rank");
SETVANV(&g2, "DegreeRank", &rank);
set_size(&g2, &size, 100);
centralization(&g2, "Betweenness");
@@ -294,21 +293,25 @@ int filter_graph() {
float percentile;
int cutsize;
if (ug_quickrun == true) {
printf("\n\nQuickrun requested.\n\n");
printf("Quickrun does no filtering, and provides layout information\n");
printf("based on Degree (nodesize), Walktrap Modularity (color), and\n");
printf("the Fructerman-Rheingold algorithm to maximize space between\n");
printf("nodes.\n\n");
printf("Quickrun is quicker, but less informative in terms of output.\n");
if (ug_verbose == true) {
printf("\n\nQuickrun requested.\n\n");
printf("Quickrun does no filtering, and provides layout information\n");
printf("based on Degree (nodesize), Walktrap Modularity (color), and\n");
printf("the Fructerman-Rheingold algorithm to maximize space between\n");
printf("nodes.\n\n");
printf("Quickrun is quicker, but less informative in terms of output.\n");
}
quickrunGraph();
igraph_destroy(&g);
return(0);
}
/* if (CALC_WEIGHTS == false) {igraph_vector_init(&WEIGHTED, NODESIZE);}*/
percentile = (ug_percent > 0.99) ? fix_percentile() : ug_percent;
cutsize = round((double)NODESIZE * percentile);
printf("Filtering the graphs by %f will reduce the graph size by %d \n", ug_percent, cutsize);
printf("This will produce a graph with %d nodes.\n", (NODESIZE - cutsize));
if (ug_verbose == true) {
printf("Filtering the graphs by %f will reduce the graph size by %d \n", ug_percent, cutsize);
printf("This will produce a graph with %d nodes.\n", (NODESIZE - cutsize));
}
SETVANV(&g, "idRef", &idRef);
analysis_all(&g);
runFilters(&g, cutsize);
View
@@ -73,24 +73,24 @@ extern int igraph_write_graph_gexf(const igraph_t *graph, FILE *outstream,
const char *vprefix= prefixattr ? "v_" : "";
const char *eprefix= prefixattr ? "e_" : "";
ret=fprintf(outstream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
ret=fprintf(outstream, "<?xml version=\"1.1\" encoding=\"UTF-8\"?>\n");
if (ret<0) IGRAPH_ERROR("Write failed", IGRAPH_EFILE);
ret=fprintf(outstream, "<gexf xmlns=\"http://www.gexf.net/1.2draft\"\n");
ret=fprintf(outstream, "<gexf xmlns=\"http://www.gexf.net/1.3draft\"\n");
if (ret<0) IGRAPH_ERROR("Write failed", IGRAPH_EFILE);
ret=fprintf(outstream, " xmlns:viz=\"http://www.gexf.net/1.2draft/viz\"\n");
ret=fprintf(outstream, " xmlns:viz=\"http://www.gexf.net/1.3draft/viz\"\n");
ret=fprintf(outstream, " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n");
if (ret<0) IGRAPH_ERROR("Write failed", IGRAPH_EFILE);
ret=fprintf(outstream, " xsi:schemaLocation=\"http://www.gexf.net/1.2draft\n");
ret=fprintf(outstream, " xsi:schemaLocation=\"http://www.gexf.net/1.3draft\n");
if (ret<0) IGRAPH_ERROR("Write failed", IGRAPH_EFILE);
ret=fprintf(outstream, " http://www.gexf.net/1.2draft/gexf.xsd\"\n");
ret=fprintf(outstream, " http://www.gexf.net/1.3draft/gexf.xsd\"\n");
if (ret<0) IGRAPH_ERROR("Write failed", IGRAPH_EFILE);
ret=fprintf(outstream, " version=\"1.2\">\n");
ret=fprintf(outstream, " version=\"1.3\">\n");
if (ret<0) IGRAPH_ERROR("Write failed", IGRAPH_EFILE);
ret=fprintf(outstream, "<!-- Created by igraph -->\n");
if (ret<0) IGRAPH_ERROR("Write failed", IGRAPH_EFILE);
ret=fprintf(outstream, "<meta lastmodifieddate=\"%.19s\">\n", ctime(&t));
if (ret<0) IGRAPH_ERROR("Write failed", IGRAPH_EFILE);
ret=fprintf(outstream, "<creator>Borg-reducer filtering using Igraph</creator>\n");
ret=fprintf(outstream, "<creator>Graphpass filtering using Igraph by Archives Unleashed</creator>\n");
if (ret<0) IGRAPH_ERROR("Write failed", IGRAPH_EFILE);
ret=fprintf(outstream, "<description> A Filtered Derivative Graph</description>\n");
if (ret<0) IGRAPH_ERROR("Write failed", IGRAPH_EFILE);
View
@@ -32,6 +32,7 @@
#include "igraph.h"
#include <stdlib.h>
#include "graphpass.h"
char* FILEPATH; /**< The filepath (ug_DIRECTORY + ug_FILENAME) */
@@ -44,8 +45,8 @@ bool ug_gformat = false;
bool ug_report = false;
/** Provide a quickrun with simple sizing, positioning and coloring **/
bool ug_quickrun = false;
int verbose_flag;
/** Print out helper messages **/
bool ug_verbose = false;
int main (int argc, char *argv[]) {
/* Experiments here
@@ -57,11 +58,9 @@ int main (int argc, char *argv[]) {
{
static struct option long_options[] =
{
/* These options set a flag. */
{"verbose", no_argument, &verbose_flag, 1},
{"brief", no_argument, &verbose_flag, 0},
/* 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'},
{"gexf", no_argument, 0, 'g'},
@@ -76,7 +75,7 @@ int main (int argc, char *argv[]) {
};
/* getopt_long stores the option index here. */
int option_index = 0;
c = getopt_long (argc, argv, "nrgqwf:p:m:o:d",
c = getopt_long (argc, argv, "vnrgqwf:p:m:o:d",
long_options, &option_index);
/* Detect the end of the options. */
@@ -88,6 +87,9 @@ int main (int argc, char *argv[]) {
/* If this option set a flag, do nothing else now. */
if (long_options[option_index].flag != 0)
break;
case 'v':
ug_verbose = true;
break;
case 'n':
ug_save = !ug_save;
break;
@@ -127,12 +129,6 @@ int main (int argc, char *argv[]) {
}
}
/* Instead of reporting ‘--verbose’
and ‘--brief’ as they are encountered,
we report the final status resulting from them. */
if (verbose_flag)
puts ("verbose flag is set");
/* Print any remaining command line arguments (not options). */
if (optind < argc)
{
@@ -154,12 +150,13 @@ int main (int argc, char *argv[]) {
strncpy(path, ug_DIRECTORY, strlen(ug_DIRECTORY)+1);
/** start output description **/
printf(">>>>>>> GRAPHPASSING >>>>>>>> \n");
printf("DIRECTORY: %s \nSTRLEN PATH: %li \n", ug_DIRECTORY, strlen(path));
printf("OUTPUT DIRECTORY: %s\nPERCENTAGE: %f\n", ug_OUTPUT, ug_percent);
printf("FILE: %s\nMETHODS STRING: %s\n", ug_FILENAME, ug_methods);
printf("QUICKRUN: %i\nREPORT: %i\nSAVE: %i\n", ug_quickrun, ug_report, ug_save);
if (ug_verbose == true) {
printf(">>>>>>> GRAPHPASSING >>>>>>>> \n");
printf("DIRECTORY: %s \nSTRLEN PATH: %li \n", ug_DIRECTORY, strlen(path));
printf("OUTPUT DIRECTORY: %s\nPERCENTAGE: %f\n", ug_OUTPUT, ug_percent);
printf("FILE: %s\nMETHODS STRING: %s\n", ug_FILENAME, ug_methods);
printf("QUICKRUN: %i\nREPORT: %i\nSAVE: %i\n", ug_quickrun, ug_report, ug_save);
}
/** try to be nice if user leaves out a '/' **/
if (ug_FILENAME[0] == '/' && ug_DIRECTORY[strlen(ug_DIRECTORY)] == '/' ){
path[strlen(path)+1] = '\0'; // remove end slash
@@ -174,10 +171,16 @@ int main (int argc, char *argv[]) {
int filepathsize = sizeOfPath + sizeOfFile;
FILEPATH = malloc(filepathsize + 1);
snprintf(FILEPATH, filepathsize, "%s%s", path, ug_FILENAME);
printf("Running graphpass on file: %s\n", FILEPATH);
if (ug_verbose == true) {
printf("Running graphpass on file: %s\n", FILEPATH);
}
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);
printf ("FAIL >>> Exiting...\n");
exit(EXIT_FAILURE);
}
/** start the filtering based on values and methods **/
filter_graph();
View
@@ -46,7 +46,9 @@ extern int load_graph (char* filename) {
}
igraph_read_graph_graphml(&g, fp, 0);
NODESIZE = igraph_vcount(&g);
printf("Successfully ingested graph with %li nodes.\n", (long int)NODESIZE);
if (ug_verbose) {
printf("Successfully ingested graph with %li nodes.\n", (long int)NODESIZE);
}
fclose(fp);
return (0);
}
@@ -87,7 +89,9 @@ extern int write_graph(igraph_t *graph, char *attr) {
strncat(path, ".graphml", 8);
}
if (ug_save == true) {
printf("Writing output to: %s\n", path);
if (ug_verbose == true) {
printf("Writing output to: %s\n", path);
}
fp = fopen(path, "w");
if (ug_gformat) {
igraph_write_graph_gexf(graph, fp, 1);
@@ -96,7 +100,6 @@ extern int write_graph(igraph_t *graph, char *attr) {
}
fclose(fp);
}
return 0;
}
View
@@ -30,11 +30,23 @@
extern int quickrunGraph() {
igraph_vector_t size;
igraph_vector_init(&size, igraph_vcount(&g));
if (ug_verbose == true)
printf ("Calculating Degree... \n");
calc_degree(&g, 'd');
if (ug_verbose == true)
printf ("Calculating Modularity... \n");
calc_modularity(&g);
if (ug_verbose == true)
printf ("Assigning Colors... \n");
colors(&g);
if (ug_verbose == true)
printf("Assigning Degree values... \n");
VANV(&g, "Degree", &size);
if (ug_verbose == true)
printf("Scaling graph with degree values... \n");
set_size(&g, &size, 100);
if (ug_verbose == true)
printf("Producing layout details... \n");
layout_graph(&g, 'f');
write_graph(&g, "-");
igraph_vector_destroy(&size);

0 comments on commit d17b57c

Please sign in to comment.