Data Structures Lerax  1.1.0
Opinionated Data Structures & Algorithms
Loading...
Searching...
No Matches
graph.h File Reference
#include <stdbool.h>
#include "../set/set.h"

Go to the source code of this file.

Typedefs

typedef struct Graph Graph
typedef enum edgeType EdgeType

Enumerations

enum  edgeType { TREE , CROSS , FORWARD , BACK }

Functions

Graphgraph_create ()
 Creates a new directed graph.
Graphgraph_undirected_create ()
 Creates a new undirected graph.
Graphgraph_tarjan_create (bool directed)
 Creates a new tarjan graph.
size_t graph_size (Graph *g)
 Get the number of nodes.
bool graph_is_directed (Graph *g)
 Check if graph is weighted.
bool graph_is_weighted (Graph *g)
 Check if graph is weighted.
void graph_add_node (Graph *g, int node)
 Adds a node to the graph.
void graph_add_edge (Graph *g, int u, int v)
 Adds an edge to the graph.
void graph_add_edge_with_weight (Graph *g, int u, int v, int weight)
 Adds a weighted edge to the graph.
int graph_get_edge_weight (Graph *g, int u, int v)
 Gets the weight of an edge.
void graph_remove_edge (Graph *g, int u, int v)
 Removes an edge from the graph.
void graph_remove_node (Graph *g, int node)
 Removes a node from the graph.
bool graph_has_edge (Graph *g, int u, int v)
 Checks if an edge exists in the graph.
bool graph_has_node (Graph *g, int u)
 Checks if a node exists in the graph.
Setgraph_get_neighbors (Graph *g, int node)
 Gets the neighbors of a node.
void graph_free (Graph *g)
 Frees the memory allocated for the graph.
void graph_print (Graph *g)
 Prints the graph.
void graph_export_to_dot (Graph *g, const char *filename)
 Exports the graph to a DOT file for visualization with Graphviz.
Iteratorgraph_bfs (Graph *g, int start_node)
 Performs a Breadth-First Search on a graph.
Iteratorgraph_dfs (Graph *g, int start_node)
 Performs a Depth-First Search on a graph.
Iteratorgraph_nodes_iterator (Graph *g)
 Iterate over nodes of the graph.
Listgraph_edges (Graph *g)
 List with edges of the graph with (key,data).
Listgraph_edges_ordered (Graph *g)
 List with edges of the graph with (key,data) ordered ascending.
int graph_edges_sum (Graph *g)
 Sum of the edge weights. If undirected, calculate (u, v) == (v, u) only once.
int graph_max_node_id (Graph *g)
 Get the maximum node id on the graph.
bool graph_acyclical (Graph *g)
 Check if graph has cycles.
bool graph_is_dag (Graph *g)
 Check if graph can be classified as Directed Acyclical Graph.
Graphgraph_tarjan (Graph *g)
 Create a new graph with tarjan arc classification as weight of the edges.
int * graph_strong_components (Graph *g)
 Create a array of strong components using tarjan algorithm.
Listgraph_topological_sort (Graph *g)
 Creat a list with the nodes in topological sort.
Graphgraph_dijkstra (Graph *g, int source)
 Run dijkstra algorithm on the graph.
Graphgraph_kruskal (Graph *g)
 Run Kruskal algorithm to get the minimum-span tree.
Graphgraph_prim (Graph *g, int start)
 Run Prim algorithm to get the minimum-span tree.
int graph_minimum_distance (Graph *g, int source, int destination)
 Run dijkstra algorithm and calculate the minimum distance.
Listgraph_shortest_path (Graph *g, int source, int destination)
 Run dijkstra algorithm and return the shortest path.

Typedef Documentation

◆ EdgeType

typedef enum edgeType EdgeType

◆ Graph

typedef struct Graph Graph

    Copyright 2025 Manoel Vilela

    Author: Manoel Vilela
   Contact: manoel_vilela@engineer.com

Organization: ITA


Enumeration Type Documentation

◆ edgeType

enum edgeType
Enumerator
TREE 
CROSS 
FORWARD 
BACK