Skip to content

Commit aaa7e1e

Browse files
committed
Remove boilerplate for testing purposes.
Take FILEPATH information out of the header (only need to ingest the graph).
1 parent 41e5f3f commit aaa7e1e

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

headers/graphpass.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ igraph_t g;
3535
igraph_attribute_table_t att;
3636
char* FILENAME; /**< The filename from -f flag. */
3737
char* DIRECTORY; /**< Directory to access FILENAME and put REPORT */
38-
char* FILEPATH; /**< The filepath (DIRECTORY + FILENAME) */
3938
char* METHODS; /**< METHODS to filter */
4039
char* OUTPUT; /**< Folder to output new graphs */
4140
char* OUTPATH; /**< Path to output folder (DIRECTORY + OUTPUT) */

src/graphpass.c

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,23 @@
3434
#include "igraph.h"
3535
#include "graphpass.h"
3636

37+
char* FILEPATH; /**< The filepath (DIRECTORY + FILENAME) */
38+
39+
/** Whether to save the graph **/
3740
bool SAVE = true;
41+
/** Graph format true for GEXF; false for GRAPHML **/
3842
bool GFORMAT = false;
43+
/** Produce a report analyzing effect of filtering on graph **/
3944
bool REPORT = false;
45+
/** Provide a quickrun with simple sizing, positioning and coloring **/
4046
bool QUICKRUN = false;
4147

4248
int verbose_flag;
4349

4450
int main (int argc, char *argv[]) {
45-
/* Experiments here */
46-
printf("test\n\n");
47-
igraph_vector_t test, test2;
48-
igraph_vector_init(&test, 10);
49-
igraph_vector_init(&test2, 10);
50-
VECTOR(test)[0] = 10; VECTOR(test)[1] = 2;
51-
VECTOR(test)[2] = 4; VECTOR(test)[3] = 7;
52-
VECTOR(test)[4] = 10; VECTOR(test)[5] = 100;
53-
VECTOR(test)[6] = 11; VECTOR(test)[7] = 99;
54-
VECTOR(test)[8] = 2; VECTOR(test)[9] = 10;
55-
produceRank(&test, &test2);
56-
printf("%f\n", VECTOR(test2)[5]);
57-
printf("%f\n", VECTOR(test2)[9]);
58-
59-
60-
/* End experiments */
61-
51+
/* Experiments here
52+
53+
End experiments */
6254

6355
int c;
6456
while (1)
@@ -149,35 +141,45 @@ int main (int argc, char *argv[]) {
149141
printf ("%s ", argv[optind++]);
150142
putchar ('\n');
151143
}
144+
145+
/** set default values if not included in flags **/
152146
OUTPUT = OUTPUT ? OUTPUT : "OUT/";
153147
PERCENT = PERCENT ? PERCENT : 0.00;
154148
METHODS = METHODS ? METHODS : "d";
155149
DIRECTORY = DIRECTORY ? DIRECTORY : "assets/";
156150
FILENAME = FILENAME ? FILENAME : "cpp2.graphml";
151+
152+
/** setup directory path DIRECTORY + FILENAME **/
157153
char path[strlen(DIRECTORY)+1];
158154
strncpy(path, DIRECTORY, strlen(DIRECTORY)+1);
155+
156+
/** start output description **/
159157
printf(">>>>>>> GRAPHPASSING >>>>>>>> \n");
160158
printf("DIRECTORY: %s \nSTRLEN PATH: %li \n", DIRECTORY, strlen(path));
161159
printf("OUTPUT DIRECTORY: %s\nPERCENTAGE: %f\n", OUTPUT, PERCENT);
162160
printf("FILE: %s\nMETHODS STRING: %s\n", FILENAME, METHODS);
163161
printf("QUICKRUN: %i\nREPORT: %i\nSAVE: %i\n", QUICKRUN, REPORT, SAVE);
162+
163+
/** try to be nice if user leaves out a '/' **/
164164
if (FILENAME[0] == '/' && DIRECTORY[strlen(DIRECTORY)] == '/' ){
165-
printf("Removing redundant slashes from filename.\n");
166-
path[strlen(path)+1] = '\0';
165+
path[strlen(path)+1] = '\0'; // remove end slash
167166
}
168167
else if (FILENAME[0] != '/' && DIRECTORY[strlen(DIRECTORY)-1] != '/') {
169-
printf("Adding slash separator.\n");
170-
strncat(path, "/", 1);
171-
printf ("Current path: %s.\n", path);
168+
strncat(path, "/", 1); // add a slash.
172169
}
170+
171+
/** set up FILEPATH to access graphml file **/
173172
int sizeOfPath = (strlen(path)+1);
174173
int sizeOfFile = (strlen(FILENAME)+1);
175174
int filepathsize = sizeOfPath + sizeOfFile;
176-
177175
FILEPATH = malloc(filepathsize + 1);
178176
snprintf(FILEPATH, filepathsize, "%s%s", path, FILENAME);
179177
printf("Running graphpass on file: %s\n", FILEPATH);
178+
179+
/** load the graphml **/
180180
load_graph(FILEPATH);
181+
free(FILEPATH);
182+
/** start the filtering based on values and methods **/
181183
filter_graph();
182184
printf("\n\n>>>> SUCCESS!");
183185
if (SAVE) {
@@ -186,6 +188,6 @@ int main (int argc, char *argv[]) {
186188
else {
187189
printf("- NO_SAVE requested, so no output.\n\n\n");
188190
}
189-
free(FILEPATH);
191+
190192
return 0;
191193
}

src/io.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ extern int load_graph (char* filename) {
4141
FILE *fp;
4242
fp = fopen(filename, "r");
4343
if (fp == 0) {
44-
printf(">>> FAILURE - Count not find graphML file at filepath location.\n");
44+
printf(">>> FAILURE - Could not find graphML file at filepath location.\n");
4545
exit (-1);
4646
}
47-
printf("Reading graphml file.\n");
4847
igraph_read_graph_graphml(&g, fp, 0);
4948
NODESIZE = igraph_vcount(&g);
5049
printf("Successfully ingested graph with %li nodes.\n", (long int)NODESIZE);

0 commit comments

Comments
 (0)