Data Structures Lerax  v3.0-104-ge031
Opinionated Data Structures & Algorithms
Loading...
Searching...
No Matches
graph.h
Go to the documentation of this file.
1
12
13#ifndef GRAPH_H
14#define GRAPH_H
15
16#include <stdbool.h>
17#include "../set/set.h"
18
19typedef struct Graph Graph;
20
27
34
41void graph_add_node(Graph *g, int node);
42
50void graph_add_edge(Graph *g, int u, int v);
51
60void graph_add_edge_with_weight(Graph *g, int u, int v, int weight);
61
62
71int graph_get_edge_weight(Graph *g, int u, int v);
72
73
81void graph_remove_edge(Graph *g, int u, int v);
82
89void graph_remove_node(Graph *g, int node);
90
99bool graph_has_edge(Graph *g, int u, int v);
100
109
116
123
131Iterator* graph_bfs(Graph *g, int start_node);
132
140Iterator* graph_dfs(Graph *g, int start_node);
141
142#endif /* GRAPH_H */
struct Graph Graph
Definition graph.h:19
Graph * graph_undirected_create()
Creates a new undirected graph.
int graph_get_edge_weight(Graph *g, int u, int v)
Gets the weight of an edge.
Set * graph_get_neighbors(Graph *g, int node)
Gets the neighbors of a node.
void graph_remove_edge(Graph *g, int u, int v)
Removes an edge from the graph.
Graph * graph_create()
Creates a new directed graph.
Iterator * graph_dfs(Graph *g, int start_node)
Performs a Depth-First Search on a graph.
void graph_add_node(Graph *g, int node)
Adds a node to the graph.
Iterator * graph_bfs(Graph *g, int start_node)
Performs a Breadth-First Search on a graph.
void graph_add_edge(Graph *g, int u, int v)
Adds an edge to the graph.
void graph_print(Graph *g)
Prints the graph.
bool graph_has_edge(Graph *g, int u, int v)
Checks if an edge exists in the graph.
void graph_free(Graph *g)
Frees the memory allocated for the graph.
void graph_remove_node(Graph *g, int node)
Removes a node from the graph.
void graph_add_edge_with_weight(Graph *g, int u, int v, int weight)
Adds a weighted edge to the graph.
struct Set Set
A basic implementation of a Set.
Definition set.h:27
A generic iterator struct.
Definition iterator.h:13