data_structures
Data Structures | Typedefs | Functions
graph.h File Reference
#include <errno.h>
#include <sys/types.h>
#include "types.h"
#include "array.h"
#include "rbt.h"
#include "utils.h"
+ Include dependency graph for graph.h:

Go to the source code of this file.

Data Structures

struct  s_graph
 A graph implemented using a set of arrays. More...
 

Typedefs

typedef struct s_graph t_graph
 

Functions

t_graphgraph_new (const t_type *type)
 Initializes a new graph with vertices of the specified type. More...
 
void graph_add_vertex (t_graph *graph, const void *v)
 Adds a vertex to the graph. More...
 
void graph_add_edge (t_graph *graph, const void *v1, const void *v2)
 Adds an edge between two vertices in the graph. More...
 
void graph_delete (t_graph *graph)
 Deletes this graph and frees all the associated data. More...
 
t_queuegraph_vertices (const t_graph *graph)
 Returns the queue with all the vertices in this graph. More...
 
t_queuegraph_adjacency (const t_graph *graph, const void *v)
 Returns the queue with all the vertices in this graph that are adjancent to the specified vertex. More...
 
int graph_adjacent (const t_graph *graph, const void *v1, const void *v2)
 Are two vertices in the graph adjacent to each other? More...
 

Function Documentation

◆ graph_add_edge()

void graph_add_edge ( t_graph graph,
const void *  v1,
const void *  v2 
)

Adds an edge between two vertices in the graph.

Parameters
v1One vertex
v2The other vertex

Definition at line 16 of file graph_add_edge.c.

◆ graph_add_vertex()

void graph_add_vertex ( t_graph graph,
const void *  v 
)

Adds a vertex to the graph.

Parameters
vThe vertex name to be copied

Definition at line 16 of file graph_add_vertex.c.

◆ graph_adjacency()

t_queue* graph_adjacency ( const t_graph graph,
const void *  v 
)

Returns the queue with all the vertices in this graph that are adjancent to the specified vertex.

Parameters
vThe vertex
Returns
The queue with all the vertices in this graph that are adjacent to the specified vertex

Definition at line 16 of file graph_adjacency.c.

◆ graph_adjacent()

int graph_adjacent ( const t_graph graph,
const void *  v1,
const void *  v2 
)

Are two vertices in the graph adjacent to each other?

Parameters
v1One vertex
v2The other vertex
Returns
1 if the vertices are adjacent, 0 otherwise

Definition at line 16 of file graph_adjacent.c.

◆ graph_delete()

void graph_delete ( t_graph graph)

Deletes this graph and frees all the associated data.

Does nothing if the argument is NULL.

Definition at line 16 of file graph_delete.c.

◆ graph_new()

t_graph* graph_new ( const t_type type)

Initializes a new graph with vertices of the specified type.

Parameters
typeThe type of vertices
Returns
The new graph

Definition at line 16 of file graph_new.c.

◆ graph_vertices()

t_queue* graph_vertices ( const t_graph graph)

Returns the queue with all the vertices in this graph.

Returns
The queue with all the vertices in this graph

Definition at line 16 of file graph_vertices.c.