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