GitHunt
RT

rtajan/matlab-tanner-graphs

Matlab tool for displaying, editing and exporting Tanner graphs.

matlab-tanner-graphs short presentation

matlab-tanner-graphs is a tool written in Matlab for displaying, editing and exporting Tanner graphs.
It is easy to use, the Tanner graph is created directly from the parity check matrix.

Using matlab-tanner-graphs

For creating a Tanner graph for the Hamming, just type the following code in Matlab :

H = [1 0 1 0 1 0 1; 0 1 1 0 0 1 1; 0 0 0 1 1 1 1]; % Hamming parity check matrix
tg = tanner_graph(H);                              % Build Tanner graph
plot(tg)                                           % Display Tanner graph

The expected output should be this Tanner graph :

Hamming_screenshot

Now you can edit this graph by grabbing the nodes and moving them.

Also, if you want to export the graph to a latex file (Tikz picture), just type the following code in Matlab

H = [1 0 1 0 1 0 1; 0 1 1 0 0 1 1; 0 0 0 1 1 1 1]; % Hamming parity check matrix
tg = tanner_graph(H);                              % Build Tanner graph
h_tg = plot(tg);                                   % Display Tanner graph and get a handle to it
% Move nodes, if you want to
h_tg.to_tikz('hamming.tex');                       % Export to a latex file

After compiling hamming.tex with pdflatex you should have :

Hamming Tikz

Languages

MATLAB100.0%

Contributors

MIT License
Created June 20, 2019
Updated December 21, 2025
rtajan/matlab-tanner-graphs | GitHunt