View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

4.5 | 11 ratings Rate this file 14 Downloads (last 30 days) File Size: 274 KB File ID: #21652 Version: 1.3
image thumbnail



Matt Dunham (view profile)


02 Oct 2008 (Updated )

Display a directed or undirected graph in a Matlab figure window.

| Watch this File

File Information

This package, (formerly called Graphlayout) is now maintained here:

Please see this site the for the latest downloads and documentation.


This file inspired A Patch For Graph Viz4 Matlab Toolbox.

MATLAB release MATLAB 7.6 (R2008a)
Other requirements Requires Matlab 2008a or newer; GraphViz available free from
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (13)
22 Nov 2016 Shusen Zhang

When I run the demos, the program is getting some error related with display a rectangle shape. Is there any solutions to that?
Error using rectangle
There is no DisplayName property on the Rectangle class.

Error in graphViz4MatlabNode/drawNode (line 193)
obj.rechandle = rectangle(...

Error in graphViz4MatlabNode/draw (line 81)

Error in graphViz4Matlab/displayGraph (line 525)

Error in graphViz4Matlab/draw (line 161)

Error in graphViz4Matlab (line 150)

Error in graphViz4MatlabDEMO1 (line 6)

25 Mar 2016 Jack Ie  
25 Mar 2016 Jack Ie

display this error only:
'neato' is not recognized as an internal or external command,
operable program or batch file.

Comment only
04 Mar 2016 aaron callard

There is a bug, in that the node id's are assumed to be in linear order in the resulting dot file.
To fix this replace the following function in Graphvizlayout.m
function readLayout(obj)
% Parse the file for the graphViz node locations and
% dimensions.
fid = fopen(obj.layoutFile,'r');
text = textscan(fid,'%s','delimiter','\n');
text = text{:};
[start,dims] = strtok(text{cellfun(@(x)~isempty(x),strfind(text,'graph [bb="'))},'"');
dims = textscan(strtok(dims,'"'),'%n','delimiter',',');
dims = dims{:}';
text(cellfun(@(x)~isempty(x),strfind(text,' -> ')))=[]; % delete edge info, we don't need it
node_id_text = text(cellfun(@(x)~isempty(x),strfind(text,'height'))); % keep only positions
node_id = str2double(strtok(node_id_text,' '));
text(cellfun(@(x)isempty(x),strfind(text,'pos')))=[]; % keep only positions
[start,remaining] = strtok(text,'"');
[locations,remaining] = strtok(remaining,'"');
locations = cellfun(@(str)textscan(str,'%n','delimiter',','),locations,'UniformOutput',false);
locations = [locations{:}];
locations = [locations{:}]';
% reorder based on id
locations(node_id,:) = locations;

I do know if this fix works in all scenarios, but it appears to work for all of mine. Without the fix, the resulting images aren't very pretty.

04 Mar 2016 aaron callard  
23 Jan 2013 Reza Farrahi Moghaddam  
11 Jan 2013 Peter Merk

Great tool! Very easy to use and nice graphics. The only thing missing is the possibility to name the edges.

18 Sep 2012 Marcel Rüland

Brilliant tool. Easy to use, very nice GUI and good idea.
Well done.

22 Jan 2012 Lie Tome

Works wonderfully well.

20 Jun 2011 haya

haya (view profile)

Hello, I'm trying to use graphViz4Matlab
I read the comments in the code and saw I can give only my adj matrix as input. I entered a 99x99 matrix and got the follow error:??? Error: File: C:\MATLAB7\work\Wlan-matrix2\graphViz4Matlab.m Line: 86 Column: 26
The expression to the left of the equals sign is not a valid target for an assignment.
In the code the line itself is:
properties(GetAccess = 'public', SetAccess = 'private')
can you please tell me what i did wrong, I expected a simple line like this wont have any problem
thank you

Comment only
28 Jul 2010 Julian Xue

Works great, but takes forever for large graphs (>1000 nodes). Is there a faster version available?

17 Apr 2010 Shicai Yang

it looks great~

12 Oct 2009 Daniel Zoran  
04 Feb 2010 1.1

Various bug fixes, as well as an additional option to color the edges.

27 Feb 2010 1.2

Now automatically adds graphViz to your system path, from within Matlab, (if running windows).

03 Mar 2010 1.3

Fixed a small bug in the setupPath() function of the util directory. Output argument was not always getting set.

Contact us