Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Using Graphviz in Matlab.
Date: Tue, 27 Oct 2009 16:06:20 +0000 (UTC)
Organization: NXP
Lines: 53
Message-ID: <hc75ps$9cp$1@fred.mathworks.com>
References: <hb526j$if1$1@fred.mathworks.com> <hb5ntm$49r$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1256659580 9625 172.30.248.35 (27 Oct 2009 16:06:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 27 Oct 2009 16:06:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 310539
Xref: news.mathworks.com comp.soft-sys.matlab:580399


"Lucio Cetto" <lcetto@nospam.mathworks.com> wrote in message <hb5ntm$49r$1@fred.mathworks.com>...
> Hello there:
> If you have the Bioinformatics Toolbox you can replace draw_dot with the following function:
> 
> function [x,y] = draw_dot(cm)
>   bg = biograph(cm);
>   dolayout(bg)
>   xy = cell2mat(get(bg.Nodes,'Position'));
>   x = xy(:,1);
>   y = xy(:,2);
> end % function draw_dot
> 
> also look at the function GRAPHCONNCOMP.
> 
> HTH
> Lucio
> 
> 
> "Owen " <owen.daniel@removethis.warwick.ac.uk> wrote in message <hb526j$if1$1@fred.mathworks.com>...
> > Hi,
> > 
> > I am trying to use Matlab for some graph theory problems, and have been trying to follow this (http://www.stanford.edu/~dgleich/demos/matlab/random_graphs/erdosreyni.html) tutorial for random graphs which uses the program Graphviz. I have also downloaded the relevant interface (http://www.mathworks.com/matlabcentral/fileexchange/4518) between matlab and graphviz.
> > 
> > However, when I try to run through the example problem (in the first link), I get an error. After entering
> > 
> > [x,y] = draw_dot(G);
> > 
> > I get the following error,
> > 
> > ??? Attempted to access node_pos(2); index out of bounds because numel(node_pos)=1.
> > 
> > Error in ==> dot_to_graph at 94
> >         y(lst_node) = node_pos(2);
> > 
> > Error in ==> draw_dot at 30
> > [trash, names, x, y] = dot_to_graph(tmpLAYOUT);  % load NEATO layout
> > 
> > Is anybody able to explain how to get around this?
> > 
> > Thank you.
You need two modifications in your matlab to Graphviz interface functions (seems that this are bugs). 
First, in dot_to_graph.m change (from line 92)
[node_pos] = sscanf(line(pos_pos:length(line)), ' pos  = "%d,%d"')';
x(lst_node) = node_pos(1);
y(lst_node) = node_pos(2);
into
[node_pos] =sscanf(line(pos_pos:length(line)), ' pos  = "%f,%f"',2)';
 x(lst_node) = round(node_pos(1));
 y(lst_node) = round(node_pos(2));
Second, in function draw_dot.m change  line 43 
labels = names(lbl_ndx);
into 
labels = cellstr(num2str(num_names(lbl_ndx)'));