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