diff --git a/d2/d32/number__of__paths_8cpp.html b/d2/d32/number__of__paths_8cpp.html new file mode 100644 index 000000000..68bff0f83 --- /dev/null +++ b/d2/d32/number__of__paths_8cpp.html @@ -0,0 +1,291 @@ + + + +
+ + + + +![]() |
+
+ 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.
+![]() |
+
+ TheAlgorithms/C++ 1.0.0
+
+ All the algorithms implemented in C++
+ |
+
A bipartite graph is the one whose nodes can be divided into two disjoint sets in such a way that the nodes in a set are not connected to each other at all, i.e. no intra-set connections. The only connections that exist are that of inter-set, i.e. the nodes from one set are connected to a subset of nodes in the other set. In this implementation, using a graph in the form of adjacency list, check whether the given graph is a bipartite or not.
References used: GeeksForGeeks
Graphical algorithms
+for std::vector for IO operations for assert for fixed-size integer types (e.g., std::uint32_t)
for std::min for IO operations for limits of integral types for std::vector
Graph Algorithms
| 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)
+| A | adjacency matrix representing the graph (1: edge exists, 0: no edge) |
| u | the starting node |
| v | the destination node |
| n | the number of nodes in the graph |
Definition at line 67 of file number_of_paths.cpp.
+| 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
+| A | adjacency matrix representing the graph (1: edge exists, 0: no edge) |
| u | the starting node |
| v | the destination node |
| n | the number of nodes in the graph |
| visited | a vector to keep track of visited nodes in the current DFS path |
Definition at line 34 of file number_of_paths.cpp.
+