Skip to content

Commit

Permalink
Enforced Linux Kernel style using clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
gabri94 committed Apr 14, 2018
1 parent dfdda64 commit 151460f
Show file tree
Hide file tree
Showing 47 changed files with 7,575 additions and 3,902 deletions.
20 changes: 20 additions & 0 deletions .clang-format
@@ -0,0 +1,20 @@
BasedOnStyle: LLVM
Language: Cpp
IndentWidth: 8
UseTab: Always
BreakBeforeBraces: Linux
AlwaysBreakBeforeMultilineStrings: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
IndentCaseLabels: false
AlignEscapedNewlinesLeft: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AlignAfterOpenBracket: true
SpaceAfterCStyleCast: false
MaxEmptyLinesToKeep: 2
BreakBeforeBinaryOperators: NonAssignment
BreakStringLiterals: false
SortIncludes: false
ContinuationIndentWidth: 8
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,6 +5,7 @@
.project
.settings/
nbproject/
build/
.idea/

#files being edited
Expand Down
58 changes: 25 additions & 33 deletions graph-parser_c/include/biconnected.h
Expand Up @@ -11,60 +11,52 @@
#include "graph/graph.h"

#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif

struct graph;
struct graph;


struct connected_component
{
struct graph g;
struct connected_component {
struct graph g;


int * mapping;
int * weights;
int *mapping;
int *weights;

struct node_graph *cutpoint;
struct node_graph *cutpoint;


int cutpoint_index;
};
int cutpoint_index;
};


struct sub_graph
{
struct list connected_components;
struct sub_graph {
struct list connected_components;


int size;
};
int size;
};


// These function returns the list of list of connected components
// i.e. a list of connected components for each connected subgraph
struct list *tarjan_rec_undir(struct graph *g,
bool * is_articulation_point,
int * component_indexes);
// These function returns the list of list of connected components
// i.e. a list of connected components for each connected subgraph
struct list *tarjan_rec_undir(struct graph *g, bool *is_articulation_point,
int *component_indexes);

struct list *tarjan_iter_undir(struct graph *g,
bool * is_articulation_point,
int * component_indexes);
struct list *tarjan_iter_undir(struct graph *g, bool *is_articulation_point,
int *component_indexes);

// not employed and completed yet (missing art_poit and
// division in subgraph with component indexing)
struct list *tarjan_rec_dir(struct graph *g,
bool * is_articulation_point,
int * component_indexes);
// not employed and completed yet (missing art_poit and
// division in subgraph with component indexing)
struct list *tarjan_rec_dir(struct graph *g, bool *is_articulation_point,
int *component_indexes);

struct list *tarjan_iter_dir(struct graph *g,
bool * is_articulation_point,
int * component_indexes);
struct list *tarjan_iter_dir(struct graph *g, bool *is_articulation_point,
int *component_indexes);

#ifdef __cplusplus
}
#endif

#endif /* BICONNECTED_H */

40 changes: 18 additions & 22 deletions graph-parser_c/include/brandes.h
Expand Up @@ -12,31 +12,27 @@
#include "biconnected.h"

#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif

/**
* This is the algorithm described in the linked papers.
* Given a network, in the form of a weighted graph, it computes the
* centrality of each node based on the amount of routes that are based on it.
* http://www.algo.uni-konstanz.de/publications/b-fabc-01.pdf
* http://algo.uni-konstanz.de/publications/b-vspbc-08.pdf
*/
double * betweeness_brandes(struct graph *g,
bool endpoints,
int * articulation_point_val,
bool normalized);
/**
* This is the algorithm described in the linked papers.
* Given a network, in the form of a weighted graph, it computes the
* centrality of each node based on the amount of routes that are based on it.
* http://www.algo.uni-konstanz.de/publications/b-fabc-01.pdf
* http://algo.uni-konstanz.de/publications/b-vspbc-08.pdf
*/
double *betweeness_brandes(struct graph *g, bool endpoints,
int *articulation_point_val, bool normalized);

/**
* This is the algorithm described in the linked paper.
* It reaches the exact results of the previous one, but it is implemented
* using a divide et impera mechanism based on biconnected components in order
* to speed up computation.
* http://algo.uni-konstanz.de/publications/pzedb-hsbcc-12.pdf
*/
double * betwenness_heuristic(struct graph *g,
bool recursive);
/**
* This is the algorithm described in the linked paper.
* It reaches the exact results of the previous one, but it is implemented
* using a divide et impera mechanism based on biconnected components in order
* to speed up computation.
* http://algo.uni-konstanz.de/publications/pzedb-hsbcc-12.pdf
*/
double *betwenness_heuristic(struct graph *g, bool recursive);

#ifdef __cplusplus
}
Expand Down
48 changes: 21 additions & 27 deletions graph-parser_c/include/graph/graph.h
Expand Up @@ -14,54 +14,48 @@

#define INVALID_NODE_GRAPH NULL
#define INVALID_EDGE_GRAPH NULL
#define INVALID_GRAPH NULL
#define NODE_GRAPH_SIZE sizeof(struct node_graph)
#define EDGE_GRAPH_SIZE sizeof(struct edge_graph)
#define GRAPH_SIZE sizeof(struct graph)
#define INVALID_GRAPH NULL
#define NODE_GRAPH_SIZE sizeof(struct node_graph)
#define EDGE_GRAPH_SIZE sizeof(struct edge_graph)
#define GRAPH_SIZE sizeof(struct graph)

/**
* Structs and functions used to represent a graph. Further detail in grap.c
*/
struct node_graph {
struct list neighbours;
char * name;
int node_graph_id;
struct list neighbours;
char *name;
int node_graph_id;
};

typedef struct node_graph * node_graph_t;
typedef struct node_graph *node_graph_t;


struct edge_graph {
struct node_graph *to;
double value;
struct node_graph *to;
double value;
};

typedef struct edge_graph * edge_graph_t;
typedef struct edge_graph *edge_graph_t;


struct graph {
struct list nodes;
bool directed;
struct list nodes;
bool directed;
};

typedef struct graph * graph_t;
typedef struct graph *graph_t;


void init_graph(graph_t g);

void add_edge_graph(graph_t g,
const char * name_from,
const char * name_to,
double value,
bool directed);

void add_edge_graph_return_node_indexes(graph_t g,
const char * name_from,
const char * name_to,
double value,
bool directed,
int * nodefrom,
int * nodeto);
void add_edge_graph(graph_t g, const char *name_from, const char *name_to,
double value, bool directed);

void add_edge_graph_return_node_indexes(graph_t g, const char *name_from,
const char *name_to, double value,
bool directed, int *nodefrom,
int *nodeto);

void free_graph(graph_t g);

Expand Down
102 changes: 46 additions & 56 deletions graph-parser_c/include/graph/list.h
Expand Up @@ -12,105 +12,95 @@
#include <stdio.h>

#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif

/**
* Structs and functions used to represent a generic list and a priority
* queue.
* The list works both with LIFO and FIFO policies.
* The priority queue offers all operation needed for dijkstra algorithm.
* The underlying implementation for both is the double linked list.
* Further detail in list.c
*/
struct node_list
{
void * content;
/**
* Structs and functions used to represent a generic list and a priority
* queue.
* The list works both with LIFO and FIFO policies.
* The priority queue offers all operation needed for dijkstra algorithm.
* The underlying implementation for both is the double linked list.
* Further detail in list.c
*/
struct node_list {
void *content;

struct node_list *next;
struct node_list *next;


struct node_list *prev;
};
struct node_list *prev;
};


struct list
{
struct node_list *head;
struct list {
struct node_list *head;


struct node_list *tail;
struct node_list *tail;


int size;
};
int size;
};


struct node_priority_queue
{
void * content;
struct node_priority_queue {
void *content;

struct node_priority_queue *next;
struct node_priority_queue *next;


struct node_priority_queue *prev;
struct node_priority_queue *prev;


double value;
};
double value;
};


struct priority_queue
{
struct node_priority_queue *head;
struct priority_queue {
struct node_priority_queue *head;


struct node_priority_queue *tail;
struct node_priority_queue *tail;


int size;
};
int size;
};


void init_list(struct list *q);
void init_list(struct list *q);

void enqueue_list(struct list *q,
void * item);
void enqueue_list(struct list *q, void *item);

void * dequeue_list(struct list *q);
void *dequeue_list(struct list *q);

void * peek_last_list(struct list *q);
void *peek_last_list(struct list *q);

void * peek_first_list(struct list *q);
void *peek_first_list(struct list *q);

void * pop_list(struct list *q);
void *pop_list(struct list *q);

void print_list(struct list *q);
void print_list(struct list *q);

void clear_list(struct list *q);
void clear_list(struct list *q);

int is_empty_list(struct list *q);
int is_empty_list(struct list *q);

void init_priority_queue(struct priority_queue *q);
void init_priority_queue(struct priority_queue *q);

void insert_priority_queue(struct priority_queue *q,
void * item,
double val);
void insert_priority_queue(struct priority_queue *q, void *item, double val);

void insert_or_update_priority_queue(struct priority_queue *q,
void * item,
double val);
void insert_or_update_priority_queue(struct priority_queue *q, void *item,
double val);

void * dequeue_priority_queue(struct priority_queue *q);
void *dequeue_priority_queue(struct priority_queue *q);

void print_priority_queue(struct priority_queue *q);
void print_priority_queue(struct priority_queue *q);

int is_empty_priority_queue(struct priority_queue *q);
int is_empty_priority_queue(struct priority_queue *q);

#ifdef __cplusplus
}
#endif

#endif /* LIST_H */

0 comments on commit 151460f

Please sign in to comment.