Mercurial > hg > octave-nkf
comparison scripts/sparse/gplot.m @ 5576:7e008607a86e
[project @ 2005-12-13 19:05:54 by jwe]
author | jwe |
---|---|
date | Tue, 13 Dec 2005 19:05:55 +0000 |
parents | |
children | 6ada1581e8b4 |
comparison
equal
deleted
inserted
replaced
5575:9b4d9dbe88f7 | 5576:7e008607a86e |
---|---|
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}) | |
20 ## @deftypefnx {Function File} {} gplot (@var{a}, @var{xy}, @var{LineSpec}) | |
21 ## @deftypefnx {Function File} {[@var{x}, @var{y}] =} gplot (@var{a}, @var{xy}) | |
22 ## Plots a graph defined by @var{A} and @var{xy} in the graph theory sense. | |
23 ## @var{A} is the adjacency matrix of the array to be plotted and @var{xy} is a | |
24 ## @var{n}-by-2 matrix containing the coordinates of the nodes of the graph. | |
25 ## | |
26 ## If defined, @var{LineStyle} defines the output style for the plot. Called | |
27 ## with no output arguments the graph is plotted directly. Called with output | |
28 ## arguments the coordinates of the plot are returned in @var{x} and @var{y}, | |
29 ## rather than being plotted. | |
30 ## @end deftypefn | |
31 ## @seealso{treeplot,etreeplot,spy} | |
32 | |
33 function [x, y] = gplot (A, xy, LineStyle) | |
34 | |
35 if (nargin < 2 || nargin > 3 || nargout > 2) | |
36 error ("gplot: wrong number of input/output arguments"); | |
37 endif | |
38 | |
39 if (nargin == 2) | |
40 LineStyle = "1;;"; | |
41 endif | |
42 | |
43 [i,j] = find(A); | |
44 xcoord = [xy(i,1), xy(j,1), NaN * ones(length(i),1)]'(:); | |
45 ycoord = [xy(i,2), xy(j,2), NaN * ones(length(i),1)]'(:); | |
46 | |
47 if (nargout == 0) | |
48 plot(xcoord,ycoord,LineStyle); | |
49 else | |
50 x = xcoord; | |
51 y = ycoord; | |
52 endif | |
53 | |
54 endfunction |