https://github.com/xiaoxiae/dfs-constant-memory
Various DFS implementations, written in C++.
https://github.com/xiaoxiae/dfs-constant-memory
Last synced: 10 months ago
JSON representation
Various DFS implementations, written in C++.
- Host: GitHub
- URL: https://github.com/xiaoxiae/dfs-constant-memory
- Owner: xiaoxiae
- License: mit
- Created: 2020-11-10T00:34:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-25T08:36:49.000Z (over 5 years ago)
- Last Synced: 2025-09-24T16:53:42.126Z (10 months ago)
- Language: C++
- Size: 33.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DFS in constant memory [WIP, not finished]
A C++ implementation of the [Linear-Time In-Place DFS and BFS on the Word RAM](https://arxiv.org/abs/1803.04282v4) article, which allows to run a DFS on a graph (given a specific representation) in constant additional memory and linear time, as opposed to a standard DFS algorithms that use O(n) additional memory.
## Sample usage
```c++
#include "lib/dfs-constant-memory.h"
#include
#include
void entering(int v) { std::cout << "Entering vector " + std::to_string(v) + "." << std::endl; }
void exiting(int v) { std::cout << "Exiting vector " + std::to_string(v) + "." << std::endl; }
int main() {
std::vector graph{5, 7, 9, 12, 14, 17, 12, 2, 5, 1, 3, 4, 2, 4, 2, 3, 5, 1, 4};
int starting_vertex = 3;
dfs_constant_memory(graph, starting_vertex, entering, exiting);
}
```