The Huffman Encoding Visualizer is a Go-based tool designed to visualize the Huffman encoding process. Utilizing the treedrawer
library by m1gwings, this project allows users to explore the intricacies of Huffman coding, a popular algorithm for data compression.
To run the Huffman Encoding Visualizer, execute the following command in your terminal:
go run main.go <input_file> [--codes | --count | --tree]
<input_file>: The path to a text file that contains the input data. The first line of the file will be read as the input string for Huffman encoding.
--codes: Displays the Huffman codes for each character in the input text.
--count: Displays the occurrence count of each character in the input text.
--tree: Visualizes the Huffman tree structure.
Go 1.16 or later The github.com/m1gwings/treedrawer/tree package for visualizing the Huffman tree. Example Input File Make sure your input file (e.g., input.txt) contains text formatted as follows:
go get github.com/m1gwings/treedrawer/tree
Display Huffman Codes:
go run main.go input.in --codes
This command will output the Huffman codes generated for each character based on the input text in input.txt.
go run main.go input.in --count
This command will print the frequency of each character present in the input text.
go run main.go input.in --tree
This command will create a visual representation of the Huffman tree based on the input text.