data_structures
graph_adjacency.c
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* graph_adjacency.c :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2020/07/22 01:42:21 by unite #+# #+# */
10 /* Updated: 2020/09/07 21:49:03 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #include "graph.h"
15 
16 t_queue *graph_adjacency(const t_graph *graph, const void *v)
17 {
18  t_array *array;
19 
20  if (!(array = rbt_get(graph->adj, v)))
21  ds_exit_set(EINVAL);
22  return (array_to_queue(array));
23 }
s_graph::adj
t_rbt * adj
The set of arrays, where each arrays represents the adjacency of a given vertex.
Definition: graph.h:43
s_graph
A graph implemented using a set of arrays.
Definition: graph.h:39
s_list
Doubly-linked list of generic items.
Definition: list.h:54
array_to_queue
t_queue * array_to_queue(const t_array *array)
Returns a queue that contains copies of the element in this array.
Definition: array_to_queue.c:16
s_array
A resizable array.
Definition: array.h:47
rbt_get
void * rbt_get(const t_rbt *rbt, const void *key)
Returns the value associated with a specified key.
Definition: rbt_get.c:16
graph.h
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.
Definition: graph_adjacency.c:16
ds_exit_set
void ds_exit_set(int err)
Set errno to the specified value, print the error message, and exit the process.
Definition: ds_exit_set.c:22