从其邻接矩阵绘制图形

5 matlab

我在MATLAB中寻找一个命令,可以帮助我绘制给定邻接矩阵的图形.谁能帮我?此外,我需要一些图形工具来计算图形上的点之间的最短距离,集合的直径,集合之间的距离等.谢谢

cMi*_*nor 4

检查Haruna Matsushita的 Matlab 函数

\n\n
function [Xout,Yout,Zout]=gplot3(A,xy,lc)\n% gplot\xe2\x80\x9a\xc3\x8c3\xc5\xbd\xc5\xb8\xc5\x92\xc2\xb3\xe2\x80\xa2\\\xc5\xbd\xc2\xa6\n%\n% 2005/04/11    Haruna MATSUSHITA\n\n%GPLOT Plot graph, as in "graph theory".\n%   GPLOT(A,xy) plots the graph specified by A and xy. A graph, G, is\n%   a set of nodes numbered from 1 to n, and a set of connections, or\n%   edges, between them.  \n%\n%   In order to plot G, two matrices are needed. The adjacency matrix,\n%   A, has a(i,j) nonzero if and only if node i is connected to node\n%   j.  The coordinates array, xy, is an n-by-2 matrix with the\n%   position for node i in the i-th row, xy(i,:) = [x(i) y(i)].\n%   \n%   GPLOT(A,xy,LineSpec) uses line type and color specified in the\n%   string LineSpec. See PLOT for possibilities.\n%\n%   [X,Y] = GPLOT(A,xy) returns the NaN-punctuated vectors\n%   X and Y without actually generating a plot. These vectors\n%   can be used to generate the plot at a later time if desired.\n%   \n%   See also SPY, TREEPLOT.\n\n%   John Gilbert, 1991.\n%   Modified 1-21-91, LS; 2-28-92, 6-16-92 CBM.\n%   Copyright 1984-2002 The MathWorks, Inc. \n%   $Revision: 5.12 $  $Date: 2002/04/09 00:26:12 $\n\n[i,j] = find(A);\n[ignore, p] = sort(max(i,j));\ni = i(p);\nj = j(p);\n\n% Create a long, NaN-separated list of line segments,\n% rather than individual segments.\n\nX = [ xy(i,1) xy(j,1) repmat(NaN,size(i))]\';\nY = [ xy(i,2) xy(j,2) repmat(NaN,size(i))]\';\nZ = [ xy(i,3) xy(j,3) repmat(NaN,size(i))]\';\nX = X(:);\nY = Y(:);\nZ = Z(:);\n\nif nargout==0,\n    if nargin<3,\n        plot3(X, Y, Z)\n    else\n        plot3(X, Y, Z,lc,\'MarkerFaceColor\',\'none\',\'MarkerEdgeColor\',\'b\',\'MarkerSize\',5);\n    end\nelse\n    Xout = X;\n    Yout = Y;\n    Zout = Z;\nend\n
Run Code Online (Sandbox Code Playgroud)\n