annotate scripts/sparse/gplot.m @ 5577:6ada1581e8b4

[project @ 2005-12-13 19:20:14 by jwe]
author jwe
date Tue, 13 Dec 2005 19:20:14 +0000
parents 7e008607a86e
children 2618a0750ae6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5576
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 2005 Ivana Varekova
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
2 ##
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
3 ## This program is free software; you can redistribute it and/or modify
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
4 ## it under the terms of the GNU General Public License as published by
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
5 ## the Free Software Foundation; either version 2 of the License, or
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
6 ## (at your option) any later version.
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
7 ##
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
8 ## This program is distributed in the hope that it will be useful,
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
11 ## GNU General Public License for more details.
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
12 ##
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
13 ## You should have received a copy of the GNU General Public License
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
14 ## along with this program; if not, write to the Free Software
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
15 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
16 ## 02110-1301 USA
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
17
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
18 ## -*- texinfo -*-
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
19 ## @deftypefn {Function File} {} gplot (@var{a}, @var{xy})
5577
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
20 ## @deftypefnx {Function File} {} gplot (@var{a}, @var{xy}, @var{line_style})
5576
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
21 ## @deftypefnx {Function File} {[@var{x}, @var{y}] =} gplot (@var{a}, @var{xy})
5577
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
22 ## Plot a graph defined by @var{A} and @var{xy} in the graph theory
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
23 ## sense. @var{A} is the adjacency matrix of the array to be plotted
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
24 ## and @var{xy} is an @var{n}-by-2 matrix containing the coordinates of
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
25 ## the nodes of the graph.
5576
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
26 ##
5577
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
27 ## The optional parameter @var{line_style} defines the output style for
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
28 ## the plot. Called with no output arguments the graph is plotted
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
29 ## directly. Otherwise, return the coordinates of the plot in @var{x}
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
30 ## and @var{y}.
5576
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
31 ## @end deftypefn
5577
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
32 ## @seealso{treeplot, etreeplot, spy}
5576
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
33
5577
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
34 function [x, y] = gplot (A, xy, line_style)
5576
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
35
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
36 if (nargin < 2 || nargin > 3 || nargout > 2)
5577
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
37 usage ("gplot (a, xy, line_style)");
5576
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
38 endif
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
39
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
40 if (nargin == 2)
5577
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
41 line_style = "1;;";
5576
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
42 endif
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
43
5577
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
44 [i, j] = find (A);
5576
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
45 xcoord = [xy(i,1), xy(j,1), NaN * ones(length(i),1)]'(:);
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
46 ycoord = [xy(i,2), xy(j,2), NaN * ones(length(i),1)]'(:);
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
47
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
48 if (nargout == 0)
5577
6ada1581e8b4 [project @ 2005-12-13 19:20:14 by jwe]
jwe
parents: 5576
diff changeset
49 plot (xcoord, ycoord, line_style);
5576
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
50 else
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
51 x = xcoord;
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
52 y = ycoord;
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
53 endif
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
54
7e008607a86e [project @ 2005-12-13 19:05:54 by jwe]
jwe
parents:
diff changeset
55 endfunction