|
Algorithms_in_C++
1.0.0
Set of algorithms implemented in C++.
|
Functions | |
| void | add_directed_edge (std::vector< std::vector< int >> *graph, int u, int v) |
| Adds a directed edge from vertex u to vertex v. More... | |
| void | add_undirected_edge (std::vector< std::vector< int >> *graph, int u, int v) |
| Adds an undirected edge from vertex u to vertex v. Essentially adds too directed edges to the adjacency list reprsentation of the graph. More... | |
| std::vector< bool > | breadth_first_search (const std::vector< std::vector< int >> &graph, int start) |
| Function performs the breadth first search algorithm over the graph. More... | |
Graph algorithms.
| void graph::add_directed_edge | ( | std::vector< std::vector< int >> * | graph, |
| int | u, | ||
| int | v | ||
| ) |
| void graph::add_undirected_edge | ( | std::vector< std::vector< int >> * | graph, |
| int | u, | ||
| int | v | ||
| ) |
Adds an undirected edge from vertex u to vertex v. Essentially adds too directed edges to the adjacency list reprsentation of the graph.
| graph | Adjacency list representation of graph |
| u | first vertex |
| v | second vertex |
| std::vector<bool> graph::breadth_first_search | ( | const std::vector< std::vector< int >> & | graph, |
| int | start | ||
| ) |
Function performs the breadth first search algorithm over the graph.
| graph | Adjacency list representation of graph |
| start | vertex from where traversing starts |
vector to keep track of visited vertices
a queue that stores vertices that need to be further explored
mark the starting vertex as visited
if the vertex is not visited then mark it as visited and push it to the queue