Permalink
Browse files

Use stdin, stdout, and stderr; resolves #47. (#63)

* Update README to reflect changes
* Remove references to libgen in Makefile (no longer used for Mac or Linux).
* Add test suite for input-output functions.
* Remove debug flags from tests and have functions return (1) instead of exit(1).
* Use #define instead of const for Ubuntu gcc.
* Use stderr instead of stdout for error outputs.
  • Loading branch information...
greebie authored and ruebot committed Oct 4, 2018
1 parent bbde012 commit 1d9c65b376ad09af306822d7c8f6ecdd0f5aa635
View
@@ -10,3 +10,7 @@ OUT
/tmp/
*.swp
.DS_Store
/TEST_OUT_FOLDER/
ana
io
qp
View
@@ -1,7 +1,8 @@
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
IGRAPH_PATH = /usr/local/
BASE_PATH = /usr/local/
IGRAPH_PATH = $(BASE_PATH)
endif
ifeq ($(UNAME), Darwin)
IGRAPH_PATH = /usr/local/Cellar/igraph/0.7.1_6/
@@ -21,34 +22,40 @@ INCLUDE = ./src/headers
DEPS = -I$(INCLUDE) -I$(IGRAPH_INCLUDE) -I$(UNITY_INCLUDE)
BUILD = build/
all: test install
all: clean test install
install: src/main/graphpass.c
gcc src/main/*.c $(DEPS) -L$(IGRAPH_LIB) -ligraph -lm -o graphpass
- ./graphpass -qn
gcc src/main/*.c $(DEPS) -L$(IGRAPH_LIB) -ligraph -lm -o graphpass
- ./graphpass -qnv
release: src/main/graphpass.c
gcc src/main/*.c $(DEPS) -L$(IGRAPH_LIB) -ligraph -lm -o graphpass
- ./graphpass -qg
- ./graphpass -qgnv
debug: ./src/main/graphpass.c
gcc -g src/main/*.c $(DEPS) -L$(IGRAPH_LIB) -ligraph -lm -o graphpass
gcc -g -Wall src/main/*.c $(DEPS) -L$(IGRAPH_LIB) -ligraph -lm -o graphpass
test: qp ana run clean
test: qp ana io run clean
qp: $(TEST_INCLUDE)runner_test_qp.c
gcc $(UNITY_INCLUDE)/unity.c $(TEST_INCLUDE)runner_test_qp.c $(DEPS) $(TEST_INCLUDE)quickrun_test.c $(HELPER_FILES) -L$(IGRAPH_LIB) -ligraph -lm -o qp
ana: $(TEST_INCLUDE)runner_test_ana.c
gcc $(UNITY_INCLUDE)/unity.c $(TEST_INCLUDE)runner_test_ana.c $(DEPS) $(TEST_INCLUDE)analyze_test.c $(HELPER_FILES) -L$(IGRAPH_LIB) -ligraph -lm -o ana
io: $(TEST_INCLUDE)runner_test_io.c
gcc $(UNITY_INCLUDE)/unity.c $(TEST_INCLUDE)runner_test_io.c $(DEPS) $(TEST_INCLUDE)io_test.c $(HELPER_FILES) -L$(IGRAPH_LIB) -ligraph -lm -o io
run:
- ./ana
./qp
./io
.PHONY : clean
clean:
rm -f qp
rm -f ana
rm -f io
rm -rf TEST_OUT_FOLDER
rm -rf $(BUILD)
rm -f graphpass
View
@@ -94,18 +94,21 @@ make
Once compiled use the following command:
```
./graphpass {FLAGS}
./graphpass {INPUT PATH} {OUTPUT PATH} {FLAGS}
```
The following flags are available:
* `--file {FILENAME}` - sets the default filename. If not set, `graphpass` will use
a default network in `src/resources`.
* `--dir {DIRECTORY}` - the path to look for {FILENAME} by default this is `src/resources/`
* `--output {OUTPUT}` - the directory to send output files such as filtered graphs and data reports.
* `--percent {PERCENT}` - a percentage to remove from the file. By default this is 0.0.
* `--method {options}` - a string of various methods through which to filter the
* `--input {FILEPATH} or -i` - The filepath of the file to run GraphPass on. If not set, GraphPass will use
a default network in `src/resources`. This will override the value in `{INPUT PATH}`.
* `--output {FILEPATH} or -o` - The filepath for outputs, overriding `{OUTPUT PATH}`. If the output path contains a filename, GraphPass will use that, otherwise it will default to the filename provided in `{INPUT PATH}`. Unless the quickpass (`-q`) is selected, the filename will also be altered to show the percentage filtered from the graph and the method used.
* `--percent {PERCENT} or -p` - a percentage to remove from the file. By default this is 0.0.
* `--method {options} or -m` - a string of various methods through which to filter the
graph.
* `--quick or -q` - GraphPass will run a basic set of algorithms for visualization with no filtering. The filename will be the same as the input filename.
* `--gexf or -g` - GraphPass will return the graph output in gexf (good for SigmaJS) instead of graphml.
* `--max-nodes {Value}` - Change default maximum number of nodes that GraphPass will accept. By default this is 50,000. Values larger than 50k may cause GraphPass to use up a computer's memory.
* `--max-edges {Value}` - Change default maximum number of edges that GraphPass will accept. By default this is 500,000. Values larger than 500k are unlikely to cause significant delays in computation time, but could result in memory issue upon visualization in Gephi or SigmaJS.
These various methods are outlined below:
@@ -122,21 +125,19 @@ These various methods are outlined below:
For example:
```
./graphpass --percent 10 --methods b --file links-for-gephi.graphml --output OUT/
./graphpass /path/to/links-for-gephi.graphml --percent 10 --methods b /path/to/output_filename
```
Will remove 10% of the graph using betweenness as a cutting measure and lay the network out. It will find `links-for-gephi.graphml` file in `src/resources` and output a new one to `/OUT` (titled `links-for-gephi10Betweenness.graphml`).
Will remove 10% of the graph using betweenness as a cutting measure and lay the network out. It will find `links-for-gephi.graphml` file in `path/to/input` and output a new one to `/path/to/output_filename.graphml` (titled `output_filename10Betweenness.graphml`).
# Optional arguments
* `--report` or `-r` : create an output report showing the impact of filtering on graph features.
* `--no-save` or `-n` : does not save any filtered files (useful if you just want a report).
* `--quick` or `-q` : provides a "quickrun" for basic
* `--gexf` or `-g` : output as a .gexf (e.g. for SigmaJS inputs) instead of .graphml.
# Troubleshooting
It is possible that you can get a "error while loading shared libraries" error in Linux. If so, try running `sudo ldconfig` to set the libraries path for your local installation of igraph.
It is possible that you can get a "error while loading shared libraries" error in Linux. If so, try running `sudo ldconfig` to set the libraries path for your local installation of igraph.
# License
View
@@ -36,65 +36,82 @@ typedef enum { FAIL, WARN, COMM } broadcast;
igraph_t g;
igraph_attribute_table_t att;
const char* ug_FILENAME; /**< The filename from -f flag. */
const char* ug_DIRECTORY; /**< Directory to access FILENAME */
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 */
bool ug_save; /**< If false, does not save graphs at all (for reports) */
char* ug_OUT; /**< A FILEPATH called using -o flag. */
char* ug_OUTFILE; /**< A FILENAME for outputting. */
char* ug_INPUT; /**< A FILEPATH called using -i flag. */
char* ug_FILENAME; /**< FILENAME extracted from stdin path. */
char* ug_PATH; /**< Directory path extracted from stdin path. */
char* ug_methods; /**< METHODS to filter. */
char* ug_OUTPATH; /**< Path to output folder. */
char* ug_OUTPUT; /**< Filename extracted from outpath, if it exists. */
char* ug_OUTARG; /**< Filepath entered as ARG. */
char* ug_DIRECTORY; /**< Directory extracted from ug_PATH. */
bool ug_TEST; /**< Flags a test (ignores some expected FAIL messages). */
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. */
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 */
igraph_vector_t WEIGHTED; /**< If greater than 0, conducts weighted analysis. */
/* Required External libraries */
/* Required External libraries. */
#define PROGRAM_NAME "GraphPass"
#define BUG_REPORT "https://www.github.com/archivesunleashed/graphpass/issues"
#define GIT_REPOSITORY "https://www.github.com/archivesunleashed/graphpass"
/* Color Presets */
/* Color Presets. */
#define COLOUR_SET_PASTEL "pastel.h"
#define COLOUR_SET_PRIMARY "primary.h"
#define COLOUR_SET_DAMPENED "dampened.h"
/* Visualization Presets */
/* Visualization Presets. */
#define VIZ_SET_SPACIOUS "viz_spacious.h"
#define VIZ_SET_LARGE "viz_large.h"
#define VIZ_SET_SMALL "vis_small.h"
/* Default Settings */
/* 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 PAGERANK_DAMPING 0.85 /**< chance random walk will not restart. */
#define LAYOUT_DEFAULT_CHAR 'f'
#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_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
/* For test suite. */
#define TEST_ARRAY_LENGTH 3 // Update as you add test examples.
#define TEST_MAX_STRING_SIZE 22
#define TEST_FILENAME_SIZE 9
#define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
struct Argument {
char* val;
struct Argument *next;
};
struct Node {
char* abbrev;
igraph_real_t val;
struct Node *next;
};
/** @struct RankNode
@brief unimplemented struct for holding the top 20 rankids for the graph.
@brief Unimplemented struct for holding the top 20 rankids for the graph.
*/
struct RankNode {
int rankids[20];
@@ -120,26 +137,30 @@ struct Node* clustering;
struct Node* pv;
struct Node* ts;
struct RankNode* ranks;
struct Argument* ug_args;
int get_directory (char *path, char **result);
int get_filename (char *path, char **result);
int shuffle(int *array, int n);
/** adds a new value to a Node **/
/** Adds a new value to a Node. **/
int push(struct Node** head_ref, igraph_real_t value, char* attr);
/** adds a new value to a RankNode **/
/** Adds a new value to a RankNode. **/
int pushRank (struct RankNode** head_ref, int rankids[20]);
int igraph_i_xml_escape(char* src, char** dest);
int pushArg (struct Argument** arg, char *value);
int igraph_write_graph_gexf(const igraph_t *graph, FILE *outstream,
igraph_bool_t prefixattr);
igraph_real_t mean_vector (igraph_vector_t *v1);
igraph_real_t variance_vector (igraph_vector_t *v1);
igraph_real_t std_vector(igraph_vector_t *v1);
igraph_real_t stderror_vector(igraph_vector_t *v1);
igraph_real_t std_error_vector(igraph_vector_t *v1);
igraph_real_t t_stat_vector(igraph_vector_t *v1);
igraph_real_t t_test_vector(igraph_vector_t *v1, igraph_real_t df);
int rankCompare(igraph_t *g1, igraph_t *g2, char* attr, igraph_real_t* result_pv, igraph_real_t* result_ts );
/** Writes the report **/
/** Writes the report. **/
int write_report(igraph_t *graph);
int colors (igraph_t *graph);
int layout_graph(igraph_t *graph, char layout);
View
@@ -49,12 +49,12 @@ igraph_real_t std_vector(igraph_vector_t *v1) {
return sqrt(variance_vector(v1));
}
igraph_real_t stderror_vector(igraph_vector_t *v1) {
igraph_real_t std_error_vector(igraph_vector_t *v1) {
return (std_vector(v1) / sqrt(igraph_vector_size(v1)));
}
igraph_real_t t_stat_vector(igraph_vector_t *v1) {
return (mean_vector(v1)/stderror_vector(v1));
return (mean_vector(v1)/std_error_vector(v1));
}
igraph_real_t t_test_vector(igraph_vector_t *v1, igraph_real_t df) {
@@ -531,4 +531,3 @@ int create_graph_csv(char* filepath, int start, int perc) {
fclose(fs);
return 0;
}
View
@@ -325,7 +325,3 @@ int filter_graph() {
igraph_vector_destroy(&idRef);
return 0;
}
Oops, something went wrong.

0 comments on commit 1d9c65b

Please sign in to comment.