Auto-completion & Graph Visualization Tool
trie is a program that combines auto-completion and trie-based graph visualization. It enables users to suggest auto-completions for a given prefix and generates a visual representation of the underlying trie structure.
A trie, or a prefix tree, is a tree-like data structure used to store a dynamic set or associative array where the keys are usually strings.
To build the project, clone the repository and run the following commands:
git clone --depth 1 https://github.com/Melkor-1/Prefix-Tree
cd Prefix-Tree
make
The executable can be installed to /usr/local/bin
directory by running:
# Note that this require root priveleges
make install
To uninstall, run:
make install
The program is designed to be used from the command line:
./auto-complete [OPTIONS] [filename]
- -k, --keep: Keep the transient .DOT file.
- -h, --help: Display the help message and exit.
- -s, --svg: Generate an .SVG file for graph visualization.
- -c, --complete PREFIX: Suggests autocompletions for a given prefix.
- -p, --prefix PREFIX: Specify a prefix for the .DOT file. (used and required for graph generation)
Examples:
# Keep the transient .DOT file and generate an SVG file from input.txt
./auto-complete -k -s input.txt
# Specify a prefix for the .DOT file and generate an SVG file from input.txt
./auto-complete -p prefix -s input.txt
# Suggest autocompletions for a given 'prefix' (read for stdin)
./auto-complete -c prefix
# Display the help message
./auto-complete -h
The core concepts and code structure of this library were adapted from the youtube video: This Data Structure could be used for Autocomplete.