![]() |
TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Algorithm to count paths between two nodes in a directed graph using DFS. More...
#include <vector>
#include <iostream>
#include <cassert>
#include <cstdint>
Go to the source code of this file.
Namespaces | |
namespace | graph |
Graph Algorithms. |
Functions | |
std::uint32_t | graph::count_paths_dfs (const std::vector< std::vector< std::uint32_t > > &A, std::uint32_t u, std::uint32_t v, std::uint32_t n, std::vector< bool > &visited) |
Helper function to perform DFS and count the number of paths from node u to node v | |
std::uint32_t | graph::count_paths (const std::vector< std::vector< std::uint32_t > > &A, std::uint32_t u, std::uint32_t v, std::uint32_t n) |
Counts the number of paths from node u to node v in a directed graph using Depth First Search (DFS) | |
static void | test () |
Self-test implementations. | |
int | main () |
Main function. |
Algorithm to count paths between two nodes in a directed graph using DFS.
This algorithm implements Depth First Search (DFS) to count the number of possible paths between two nodes in a directed graph. It is represented using an adjacency matrix. The algorithm recursively traverses the graph to find all paths from the source node u to the destination node v.
Definition in file number_of_paths.cpp.
int main | ( | void | ) |
Main function.
Definition at line 148 of file number_of_paths.cpp.
|
static |
Self-test implementations.
Definition at line 86 of file number_of_paths.cpp.