Mercurial > hg > octave-nkf
comparison scripts/sparse/gplot.m @ 11471:994e2a93a8e2
Use uppercase 'A' to refer to matrix inputs in m-files.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 09 Jan 2011 16:01:05 -0800 |
parents | be55736a0783 |
children | fd0a3ac60b0e |
comparison
equal
deleted
inserted
replaced
11470:eb9e0b597d61 | 11471:994e2a93a8e2 |
---|---|
15 ## You should have received a copy of the GNU General Public License | 15 ## You should have received a copy of the GNU General Public License |
16 ## along with Octave; see the file COPYING. If not, see | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | 17 ## <http://www.gnu.org/licenses/>. |
18 | 18 |
19 ## -*- texinfo -*- | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {} gplot (@var{a}, @var{xy}) | 20 ## @deftypefn {Function File} {} gplot (@var{A}, @var{xy}) |
21 ## @deftypefnx {Function File} {} gplot (@var{a}, @var{xy}, @var{line_style}) | 21 ## @deftypefnx {Function File} {} gplot (@var{A}, @var{xy}, @var{line_style}) |
22 ## @deftypefnx {Function File} {[@var{x}, @var{y}] =} gplot (@var{a}, @var{xy}) | 22 ## @deftypefnx {Function File} {[@var{x}, @var{y}] =} gplot (@var{A}, @var{xy}) |
23 ## Plot a graph defined by @var{A} and @var{xy} in the graph theory | 23 ## Plot a graph defined by @var{A} and @var{xy} in the graph theory |
24 ## sense. @var{A} is the adjacency matrix of the array to be plotted | 24 ## sense. @var{A} is the adjacency matrix of the array to be plotted |
25 ## and @var{xy} is an @var{n}-by-2 matrix containing the coordinates of | 25 ## and @var{xy} is an @var{n}-by-2 matrix containing the coordinates of |
26 ## the nodes of the graph. | 26 ## the nodes of the graph. |
27 ## | 27 ## |
30 ## directly. Otherwise, return the coordinates of the plot in @var{x} | 30 ## directly. Otherwise, return the coordinates of the plot in @var{x} |
31 ## and @var{y}. | 31 ## and @var{y}. |
32 ## @seealso{treeplot, etreeplot, spy} | 32 ## @seealso{treeplot, etreeplot, spy} |
33 ## @end deftypefn | 33 ## @end deftypefn |
34 | 34 |
35 function [x, y] = gplot (a, xy, line_style) | 35 function [x, y] = gplot (A, xy, line_style) |
36 | 36 |
37 if (nargin < 2 || nargin > 3 || nargout > 2) | 37 if (nargin < 2 || nargin > 3 || nargout > 2) |
38 print_usage (); | 38 print_usage (); |
39 endif | 39 endif |
40 | 40 |
41 if (nargin == 2) | 41 if (nargin == 2) |
42 line_style = "-"; | 42 line_style = "-"; |
43 endif | 43 endif |
44 | 44 |
45 [i, j] = find (a); | 45 [i, j] = find (A); |
46 xcoord = [xy(i,1), xy(j,1), NaN(length(i),1) ]'(:); | 46 xcoord = [xy(i,1), xy(j,1), NaN(length(i),1) ]'(:); |
47 ycoord = [xy(i,2), xy(j,2), NaN(length(i),1) ]'(:); | 47 ycoord = [xy(i,2), xy(j,2), NaN(length(i),1) ]'(:); |
48 | 48 |
49 if (nargout == 0) | 49 if (nargout == 0) |
50 plot (xcoord, ycoord, line_style); | 50 plot (xcoord, ycoord, line_style); |