我正在使用Graphviz for matlab。有一种方法可以删除最终图中没有边缘的节点,因为我的图形非常大(~9100个节点)以及以更好的方式表示图形的任何其他帮助不胜感激。
答案 0 :(得分:1)
graphviz
的输入为adjacency matrix,因此您可以执行以下操作:
% Generate random adjacency matrix with no nodes connected to themselves
N = 10;
adj = (randi(N, N) > 5) .* (ones(N) - eye(N));
% Spuriously set one row and column to zero: no connections for this node
adj(:, 2) = 0; adj(2, :) = 0;
% Find the nodes with no edges
noEdgeNodes = all(adj == 0, 1) & all(adj == 0, 2)'
noEdgeNodes =
0 1 0 0 0 0 0 0 0 0
% Remove nodes with no edges
adj(noEdgeNodes, :) = [];
adj(:, noEdgeNodes) = [];
% Call graphviz
graphViz4Matlab('-adjMat', adj, '-nodeLabels', ...
arrayfun(@(x){num2str(x)}, 1:size(adj, 1)))