[parser] using a bipartite graph (indptr + indices) to represent postal code<=>admin relationships instead of a set of 64-bit ints. Requires |V(postal codes)| + |E| 32 bit ints instead of |E| 64 bit ints. Saves several hundred MB in file size and even more space in memory because of the hashtable overhead

This commit is contained in:
Al
2017-03-18 06:05:28 -04:00
parent cb112f0ea7
commit c67678087f
7 changed files with 94 additions and 86 deletions

View File

@@ -27,6 +27,7 @@ Currently we're not implementing edge types, graph traversal, etc.
#include "collections.h"
#include "file_utils.h"
#include "vector.h"
#include "vector_math.h"
typedef enum {
GRAPH_DIRECTED,
@@ -55,8 +56,11 @@ void graph_clear(graph_t *self);
void graph_append_edge(graph_t *self, uint32_t col);
void graph_append_edges(graph_t *self, uint32_t *col, size_t n);
void graph_finalize_vertex_no_sort(graph_t *self);
void graph_finalize_vertex(graph_t *self);
bool graph_has_edge(graph_t *self, uint32_t i, uint32_t j);
bool graph_write(graph_t *self, FILE *f);
bool graph_save(graph_t *self, char *path);
graph_t *graph_read(FILE *f);