Skip to content

🌳 Un package pour travailler avec les arbres de Huffman

License

Notifications You must be signed in to change notification settings

eloidrai/huffman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Huffman coding

Usage

Huffman coding

  -s SAMPLE   --sample=SAMPLE   The set of symbols to use to create the tree
  -h          --help            Displays this help message
  -t          --tree, --dot     The tree in .dot format
  -a          --canonical       Use the canonical Huffman code for generating the codewords, encoding and decoding
  -c          --codewords       The list of the codewords
  -e MESSAGE  --encode=MESSAGE  Encodes a message
  -d MESSAGE  --decode=MESSAGE  Decodes a message

Printing Huffman trees

This executable allows you to print the representation of the binary tree using the dot syntax.

Example : huffman -s "this is a huffman tree" -t | dot -Tpng -o tree.png

The tree

Encoding/decoding examples

Encoding :

$ huffman -s "coucoutoi" -e "touco"
01111100011

Decoding :

$ huffman -s "coucoutoi" -d "01111100011"
touco

Getting the canonical codewords

The canonical Huffman code is a particular kind of huffman coding which makes it unique.

$ huffman -s "this is a huffman tree" -ca
  -> 000
i -> 100
s -> 101
t -> 110
a -> 1110
e -> 1111
f -> 1000
h -> 1001
m -> 1010
n -> 1011
r -> 1100
u -> 1101

About

🌳 Un package pour travailler avec les arbres de Huffman

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published