Thread Subject: Using Graphviz in Matlab.

Subject: Using Graphviz in Matlab.

From: Owen

Date: 14 Oct, 2009 17:36:20

Message: 1 of 3

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.

Subject: Using Graphviz in Matlab.

From: Lucio Cetto

Date: 14 Oct, 2009 23:47:02

Message: 2 of 3

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.

Subject: Using Graphviz in Matlab.

From: Predrag

Date: 27 Oct, 2009 16:06:20

Message: 3 of 3

"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)'));

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com