Graphpass  0.0.2
A helper library for network filtering, analysis and visualization
graphpass.h
1 /* -*- Graphpass -- Network Graph Utilities mode: C -*- */
2 /* Copyright [2018] [Ryan Deschamps]
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License. */
15 
16 
17 #ifndef LIB_GRAPHPASS_H
18 #define LIB_GRAPHPASS_H
19 
20 #include <igraph.h>
21 #include <stdio.h>
22 #include <math.h>
23 #include <string.h>
24 #include <stdlib.h>
25 #include <time.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <unistd.h>
29 #include <errno.h>
30 #include <getopt.h>
31 
32 typedef enum { false, true } bool;
33 
34 igraph_t g;
35 igraph_attribute_table_t att;
36 char* FILENAME;
37 char* DIRECTORY;
38 char* FILEPATH;
39 char* METHODS;
40 char* OUTPUT;
41 char* OUTPATH;
42 igraph_integer_t NODESIZE;
43 float PERCENT;
44 bool REPORT;
45 bool GFORMAT;
46 bool QUICKRUN;
47 bool SAVE;
48 bool CALC_WEIGHTS;
49 igraph_vector_t WEIGHTED;
51 /* Required External libraries */
52 
53 #define PROGRAM_NAME "Graph Pass"
54 #define BUG_REPORT "ryan.deschamps@gmail.com"
55 #define GIT_REPOSITORY "https://www.github.com/archivesunleashed/graphpass"
56 
57 /* Color Presets */
58 
59 #define COLOUR_SET_PASTEL "pastel.h"
60 #define COLOUR_SET_PRIMARY "primary.h"
61 #define COLOUR_SET_DAMPENED "dampened.h"
62 
63 /* Visualization Presets */
64 
65 #define VIZ_SET_SPACIOUS "viz_spacious.h"
66 #define VIZ_SET_LARGE "viz_large.h"
67 #define VIZ_SET_SMALL "vis_small.h"
68 
69 /* Required External libraries */
70 #define MAX_METHODS 9
71 #define ALL_METHODS 'abcdehioprw'
72 #define SIZE_DEFAULT "Degree"
73 #define SIZE_DEFAULT_CHAR 'd'
74 #define COLOR_BASE "WalkTrapModularity"
75 #define PAGERANK_DAMPING 0.85
76 #define LAYOUT_DEFAULT_CHAR = 'f'
77 
78 #define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
79 
80 struct Node {
81  char* abbrev;
82  igraph_real_t val;
83  struct Node *next;
84 };
85 
89 struct RankNode {
90  int rankids[20];
91  struct RankNode *next;
92 };
93 
94 struct stat;
95 struct Node* asshead;
96 struct Node* edges;
97 struct Node* density;
98 struct Node* betcent;
99 struct Node* reciprocity;
100 struct Node* degcent;
101 struct Node* idegcent;
102 struct Node* odegcent;
103 struct Node* eigcent;
104 struct Node* pagecent;
105 struct Node* diameter;
106 struct Node* pathlength;
107 struct Node* clustering;
108 struct RankNode* ranks;
109 
110 int shuffle(int *array, int n);
112 int push(struct Node** head_ref, igraph_real_t value, char* attr);
113 
115 int pushRank (struct RankNode** head_ref, int rankids[20]);
116 int igraph_i_xml_escape(char* src, char** dest);
117 
118 int igraph_write_graph_gexf(const igraph_t *graph, FILE *outstream,
119  igraph_bool_t prefixattr);
120 
122 int write_report(igraph_t *graph);
123 int colors (igraph_t *graph);
124 int layout_graph(igraph_t *graph, char layout);
125 int set_size(igraph_t *graph, igraph_vector_t *v, int max);
126 
127 int strip_ext(char *fname);
128 int load_graph (char* filename);
129 int write_graph(igraph_t *graph, char *attr);
130 extern int calc_betweenness(igraph_t *graph);
131 extern int calc_authority(igraph_t *graph);
132 extern int calc_hub(igraph_t *graph);
133 extern int calc_pagerank(igraph_t *graph);
134 extern int calc_eigenvector(igraph_t *graph);
135 /* extern int calc_clustering(igraph_t *graph); */
136 /* extern int calc_random(igraph_t *graph); */
137 extern int calc_degree(igraph_t *graph, char type);
138 extern int calc_modularity(igraph_t *graph);
139 extern int centralization(igraph_t *graph, char* attr);
140 extern int analysis_all (igraph_t *graph);
141 int quickrunGraph();
142 
143 float fix_percentile();
144 int create_filtered_graph(igraph_t *graph, double cutoff, int cutsize, char* attr);
145 int shrink (igraph_t *graph, int cutsize, char* attr);
146 int runFilters (igraph_t *graph, int cutsize);
147 int filter_graph();
148 
149 #endif
int filter_graph()
Definition: filter.c:278
int push(struct Node **head_ref, igraph_real_t value, char *attr)
Definition: reports.c:31
int calc_hub(igraph_t *graph)
Definition: analyze.c:72
int set_size(igraph_t *graph, igraph_vector_t *v, int max)
Definition: viz.c:155
int calc_pagerank(igraph_t *graph)
Definition: analyze.c:90
int calc_modularity(igraph_t *graph)
Definition: analyze.c:166
int igraph_i_xml_escape(char *src, char **dest)
Definition: gexf.c:18
float fix_percentile()
Definition: filter.c:32
int pushRank(struct RankNode **head_ref, int rankids[20])
Definition: reports.c:41
int calc_degree(igraph_t *graph, char type)
Definition: analyze.c:135
int write_report(igraph_t *graph)
Definition: reports.c:52
int layout_graph(igraph_t *graph, char layout)
Definition: viz.c:115
unimplemented struct for holding the top 20 rankids for the graph.
Definition: graphpass.h:89
int centralization(igraph_t *graph, char *attr)
Definition: analyze.c:198
int colors(igraph_t *graph)
Definition: viz.c:26
int calc_eigenvector(igraph_t *graph)
Definition: analyze.c:107
int calc_authority(igraph_t *graph)
Definition: analyze.c:53
int analysis_all(igraph_t *graph)
Definition: analyze.c:224
int create_filtered_graph(igraph_t *graph, double cutoff, int cutsize, char *attr)
Definition: filter.c:49
int shuffle(int *array, int n)
Definition: rnd.c:36
int calc_betweenness(igraph_t *graph)
Definition: analyze.c:36
int igraph_write_graph_gexf(const igraph_t *graph, FILE *outstream, igraph_bool_t prefixattr)
Definition: gexf.c:59
Holds graph level values for each graph that has been filtered.
Definition: graphpass.h:80