ユーザーからの入力として隣接行列を受け取り、行列の 3D 散布図を作成するコードを作成しました。ノードがノードに作用する正味の力に応じて変位するように、接続されていないノード間に反発力を割り当て、接続されたノード間に引力を割り当てたいと考えています。これは 3D でなければなりません。
2452 次
1 に答える
1
次の例は、隣接行列と頂点の座標を指定して、グラフの 3D 散布図をプロットする方法を示しています。
%# sample adjacency matrix and 3D coordinates of points
N = 30; %# number of vertices
[adj,XYZ] = bucky;
adj = full(adj); adj = adj(1:N,1:N);
x = XYZ(1:N,1); y = XYZ(1:N,2); z = XYZ(1:N,3);
labels = cellstr( num2str((1:N)','%02d') ); %'# nodes labels
%# another sample data
%#x = rand(N,1); %# x-coords of vertices
%#y = rand(N,1); %# y-coords
%#z = rand(N,1); %# z-coords
%#adj = rand(N,N)>0.7; %# adjacency matrix
%# plot graph in 3D
[r c] = find(adj);
p = [r c]'; %'# indices
plot3(x(p), y(p), z(p), 'LineWidth',2, 'Color',[.4 .4 1], ...
'Marker','o', 'MarkerSize',10, ...
'MarkerFaceColor','g', 'MarkerEdgeColor','g')
text(x, y, z, labels, ...
'EdgeColor','g', 'BackgroundColor',[.7 1 .7], ...
'VerticalAlignment','bottom', 'HorizontalAlignment','left')
axis vis3d, box on, view(3)
xlabel('x'), ylabel('y'), zlabel('z')
残念ながら、他の部分はもっと複雑であり、誰かがあなたを助けようとする前に、あなたがそれにある程度の努力を払っていることを示す必要があります...
于 2011-07-14T22:43:41.720 に答える