2013-04-12 87 views
0

我正在使用Graphviz for matlab.Is有一種方法可以刪除最終圖形中沒有邊緣的節點,因爲我的圖形非常大(約9100個節點)和任何其他有助於以更好的方式表示圖表,我們將不勝感激。Graphviz for Matlab:刪除沒有邊緣的節點

+0

你是如何生成圖形?從代碼?如果是這樣,請張貼一些。 – wakjah

+0

我使用了我在網上找到的graphviz函數...作爲輸入,我提供了一個二進制矩陣,使用該函數生成一個圖形。 –

+0

該功能的代碼部分是相當大的.... https://code.google.com/p/graphviz4matlab/downloads/list –

回答

1

輸入到graphvizadjacency 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))) 
+0

非常感謝你......它工作:) –