Mercurial > octave
annotate scripts/sparse/gplot.m @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | 7854d5752dd2 |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
3 ## Copyright (C) 2005-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
5576 | 7 ## |
7016 | 8 ## This file is part of Octave. |
5576 | 9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
7016 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
7016 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
5576 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
7016 | 21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
5576 | 25 |
26 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
27 ## @deftypefn {} {} gplot (@var{A}, @var{xy}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
28 ## @deftypefnx {} {} gplot (@var{A}, @var{xy}, @var{line_style}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
29 ## @deftypefnx {} {[@var{x}, @var{y}] =} gplot (@var{A}, @var{xy}) |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
30 ## Plot a graph defined by @var{A} and @var{xy} in the graph theory sense. |
5576 | 31 ## |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
32 ## @var{A} is the adjacency matrix of the array to be plotted and @var{xy} is |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
33 ## an @var{n}-by-2 matrix containing the coordinates of the nodes of the graph. |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
34 ## |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
35 ## The optional parameter @var{line_style} defines the output style for the |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20164
diff
changeset
|
36 ## plot. Called with no output arguments the graph is plotted directly. |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
37 ## Otherwise, return the coordinates of the plot in @var{x} and @var{y}. |
5642 | 38 ## @seealso{treeplot, etreeplot, spy} |
5576 | 39 ## @end deftypefn |
40 | |
11471
994e2a93a8e2
Use uppercase 'A' to refer to matrix inputs in m-files.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
41 function [x, y] = gplot (A, xy, line_style) |
5576 | 42 |
28789
28de41192f3c
Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
43 if (nargin < 2) |
6046 | 44 print_usage (); |
5576 | 45 endif |
46 | |
47 if (nargin == 2) | |
6746 | 48 line_style = "-"; |
5576 | 49 endif |
50 | |
11471
994e2a93a8e2
Use uppercase 'A' to refer to matrix inputs in m-files.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
51 [i, j] = find (A); |
10547
af55e4a499e4
Fix parsing error when NaN used inside of matrix declaration
Rik <code@nomad.inbox5.com>
parents:
10540
diff
changeset
|
52 xcoord = [xy(i,1), xy(j,1), NaN(length(i),1) ]'(:); |
af55e4a499e4
Fix parsing error when NaN used inside of matrix declaration
Rik <code@nomad.inbox5.com>
parents:
10540
diff
changeset
|
53 ycoord = [xy(i,2), xy(j,2), NaN(length(i),1) ]'(:); |
5576 | 54 |
55 if (nargout == 0) | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
56 plot (xcoord, ycoord, line_style); |
5576 | 57 else |
58 x = xcoord; | |
59 y = ycoord; | |
60 endif | |
61 | |
62 endfunction | |
13087
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
63 |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
64 |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
65 %!demo |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
66 %! ## Binary Tree Representation |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
67 %! A = [0 1 0 0 0 0 0 |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
68 %! 1 0 1 1 0 0 0 |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
69 %! 0 1 0 0 0 0 0 |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
70 %! 0 1 0 0 1 0 0 |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
71 %! 0 0 0 1 0 1 1 |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
72 %! 0 0 0 0 1 0 0 |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
73 %! 0 0 0 0 1 0 0]; |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
74 %! |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
75 %! xy = [1 , 0 |
13087
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
76 %! 1.5, 1 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
77 %! 2 , 0 |
13087
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
78 %! 2.5, 2 |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
79 %! 3.5, 1 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
80 %! 3 , 0 |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
81 %! 4 , 0]; |
13087
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
82 %! |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
83 %! clf; |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
84 %! gplot (A, xy, "o-"); |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
85 %! set (get (gca, ("children")), "markersize", 12); |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
86 %! title ("gplot() of Binary Tree Adjacency matrix"); |
71ce008332e2
codesprint: Add demo block to gplot.m
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
87 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
88 ## Mark graphical function as tested by demo block |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
89 %!assert (1) |