<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263130</link>
    <title>MATLAB Central Newsreader - Using Graphviz in Matlab.</title>
    <description>Feed for thread: Using Graphviz in Matlab.</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 14 Oct 2009 17:36:20 -0400</pubDate>
      <title>Using Graphviz in Matlab.</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263130#687013</link>
      <author>Owen </author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
I am trying to use Matlab for some graph theory problems, and have been trying to follow this (&lt;a href=&quot;http://www.stanford.edu/~dgleich/demos/matlab/random_graphs/erdosreyni.html)&quot;&gt;http://www.stanford.edu/~dgleich/demos/matlab/random_graphs/erdosreyni.html)&lt;/a&gt; tutorial for random graphs which uses the program Graphviz. I have also downloaded the relevant interface (&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/4518)&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/4518)&lt;/a&gt; between matlab and graphviz.&lt;br&gt;
&lt;br&gt;
However, when I try to run through the example problem (in the first link), I get an error. After entering&lt;br&gt;
&lt;br&gt;
[x,y] = draw_dot(G);&lt;br&gt;
&lt;br&gt;
I get the following error,&lt;br&gt;
&lt;br&gt;
??? Attempted to access node_pos(2); index out of bounds because numel(node_pos)=1.&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; dot_to_graph at 94&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;y(lst_node) = node_pos(2);&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; draw_dot at 30&lt;br&gt;
[trash, names, x, y] = dot_to_graph(tmpLAYOUT);  % load NEATO layout&lt;br&gt;
&lt;br&gt;
Is anybody able to explain how to get around this?&lt;br&gt;
&lt;br&gt;
Thank you.</description>
    </item>
    <item>
      <pubDate>Wed, 14 Oct 2009 23:47:02 -0400</pubDate>
      <title>Re: Using Graphviz in Matlab.</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263130#687094</link>
      <author>Lucio Cetto</author>
      <description>Hello there:&lt;br&gt;
If you have the Bioinformatics Toolbox you can replace draw_dot with the following function:&lt;br&gt;
&lt;br&gt;
function [x,y] = draw_dot(cm)&lt;br&gt;
&amp;nbsp;&amp;nbsp;bg = biograph(cm);&lt;br&gt;
&amp;nbsp;&amp;nbsp;dolayout(bg)&lt;br&gt;
&amp;nbsp;&amp;nbsp;xy = cell2mat(get(bg.Nodes,'Position'));&lt;br&gt;
&amp;nbsp;&amp;nbsp;x = xy(:,1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;y = xy(:,2);&lt;br&gt;
end % function draw_dot&lt;br&gt;
&lt;br&gt;
also look at the function GRAPHCONNCOMP.&lt;br&gt;
&lt;br&gt;
HTH&lt;br&gt;
Lucio&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Owen &quot; &amp;lt;owen.daniel@removethis.warwick.ac.uk&amp;gt; wrote in message &amp;lt;hb526j$if1$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I am trying to use Matlab for some graph theory problems, and have been trying to follow this (&lt;a href=&quot;http://www.stanford.edu/~dgleich/demos/matlab/random_graphs/erdosreyni.html)&quot;&gt;http://www.stanford.edu/~dgleich/demos/matlab/random_graphs/erdosreyni.html)&lt;/a&gt; tutorial for random graphs which uses the program Graphviz. I have also downloaded the relevant interface (&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/4518)&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/4518)&lt;/a&gt; between matlab and graphviz.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; However, when I try to run through the example problem (in the first link), I get an error. After entering&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; [x,y] = draw_dot(G);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I get the following error,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ??? Attempted to access node_pos(2); index out of bounds because numel(node_pos)=1.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Error in ==&amp;gt; dot_to_graph at 94&lt;br&gt;
&amp;gt;         y(lst_node) = node_pos(2);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Error in ==&amp;gt; draw_dot at 30&lt;br&gt;
&amp;gt; [trash, names, x, y] = dot_to_graph(tmpLAYOUT);  % load NEATO layout&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Is anybody able to explain how to get around this?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thank you.</description>
    </item>
    <item>
      <pubDate>Tue, 27 Oct 2009 16:06:20 -0400</pubDate>
      <title>Re: Using Graphviz in Matlab.</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263130#690085</link>
      <author>Predrag </author>
      <description>&quot;Lucio Cetto&quot; &amp;lt;lcetto@nospam.mathworks.com&amp;gt; wrote in message &amp;lt;hb5ntm$49r$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hello there:&lt;br&gt;
&amp;gt; If you have the Bioinformatics Toolbox you can replace draw_dot with the following function:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; function [x,y] = draw_dot(cm)&lt;br&gt;
&amp;gt;   bg = biograph(cm);&lt;br&gt;
&amp;gt;   dolayout(bg)&lt;br&gt;
&amp;gt;   xy = cell2mat(get(bg.Nodes,'Position'));&lt;br&gt;
&amp;gt;   x = xy(:,1);&lt;br&gt;
&amp;gt;   y = xy(:,2);&lt;br&gt;
&amp;gt; end % function draw_dot&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; also look at the function GRAPHCONNCOMP.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; HTH&lt;br&gt;
&amp;gt; Lucio&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &quot;Owen &quot; &amp;lt;owen.daniel@removethis.warwick.ac.uk&amp;gt; wrote in message &amp;lt;hb526j$if1$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I am trying to use Matlab for some graph theory problems, and have been trying to follow this (&lt;a href=&quot;http://www.stanford.edu/~dgleich/demos/matlab/random_graphs/erdosreyni.html)&quot;&gt;http://www.stanford.edu/~dgleich/demos/matlab/random_graphs/erdosreyni.html)&lt;/a&gt; tutorial for random graphs which uses the program Graphviz. I have also downloaded the relevant interface (&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/4518)&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/4518)&lt;/a&gt; between matlab and graphviz.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; However, when I try to run through the example problem (in the first link), I get an error. After entering&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; [x,y] = draw_dot(G);&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I get the following error,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; ??? Attempted to access node_pos(2); index out of bounds because numel(node_pos)=1.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Error in ==&amp;gt; dot_to_graph at 94&lt;br&gt;
&amp;gt; &amp;gt;         y(lst_node) = node_pos(2);&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Error in ==&amp;gt; draw_dot at 30&lt;br&gt;
&amp;gt; &amp;gt; [trash, names, x, y] = dot_to_graph(tmpLAYOUT);  % load NEATO layout&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Is anybody able to explain how to get around this?&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thank you.&lt;br&gt;
You need two modifications in your matlab to Graphviz interface functions (seems that this are bugs). &lt;br&gt;
First, in dot_to_graph.m change (from line 92)&lt;br&gt;
[node_pos] = sscanf(line(pos_pos:length(line)), ' pos  = &quot;%d,%d&quot;')';&lt;br&gt;
x(lst_node) = node_pos(1);&lt;br&gt;
y(lst_node) = node_pos(2);&lt;br&gt;
into&lt;br&gt;
[node_pos] =sscanf(line(pos_pos:length(line)), ' pos  = &quot;%f,%f&quot;',2)';&lt;br&gt;
&amp;nbsp;x(lst_node) = round(node_pos(1));&lt;br&gt;
&amp;nbsp;y(lst_node) = round(node_pos(2));&lt;br&gt;
Second, in function draw_dot.m change  line 43 &lt;br&gt;
labels = names(lbl_ndx);&lt;br&gt;
into &lt;br&gt;
labels = cellstr(num2str(num_names(lbl_ndx)'));</description>
    </item>
  </channel>
</rss>

