GraphViz4Matlab 安裝

GraphViz4Matlab + Matlab2015a + Windows7

GraphViz4Matlab 是一個MATLAB toolbox,能夠利用GraphViz提供的一些exe繪圖。
原始鏈接:Matlab Central FileExchange
後來說在Github上維護了: –Link–

(1) GraphViz的安裝

Notes on how to build Graphviz on Windows. N.B. Except in rare cases, such as a desire to modify the core Graphviz code, there is no need to build Graphviz on Windows from source. We strongly recommend that one should just install one of the available binary packages from here. If you insist, we will answer questions but basically you are on your own.

我的PC是win7,所以下載windows exe:
這裏寫圖片描述
安裝完成之後,添加“C:\Program Files (x86)\Graphviz2.38\bin”路徑到System Path中【注意路徑要以自己的安裝路徑爲準,這個bin文件夾內包含很多的exe,可以看一下哦】:
這裏寫圖片描述
GraphViz 安裝完畢~

(2) GraphViz4Matlab 調用 GraphViz

在MATLAB命令行運行以下代碼:

addpath(genpath('D:\m_func\graphViz4Matlab_03Mar2010\graphViz4Matlab'));% 注意這個路徑應該是下載解壓後的graphViz4Matlab路徑

load smallExample 
nodeColors = {'g','b','r','c'}; % if too few specified, it will cycle through
edgeColors = {'Tom', 'Bill', 'r'
              'Bill' 'all' , 'g'};

graphViz4Matlab('-adjMat',adj,'-nodeLabels',names,'-layout',Treelayout,'-nodeColors',nodeColors,'-edgeColors', edgeColors);

發現報錯:

neato - graphviz version 2.38.0 (20140413.2041) 
dot - graphviz version 2.38.0 (20140413.2041) 
twopi - graphviz version 2.38.0 (20140413.2041) 
neato - graphviz version 2.38.0 (20140413.2041) 
fdp - graphviz version 2.38.0 (20140413.2041) 
dot - graphviz version 2.38.0 (20140413.2041) 
錯誤使用 rectangle
Rectangle 類中沒有 DisplayName 屬性。

出錯 graphViz4MatlabNode/drawNode (line 193)
            obj.rechandle = rectangle(...

這應該是代碼和我的Matlab2015a兼容性問題了。
這個bug已經有人在Github上問過了,”Pull Requests” 中(–link–):
解決辦法:刪除\util\graphViz4MatlabNode.m中201行!
這裏寫圖片描述

修改之後再執行上述m代碼:
這裏寫圖片描述

Bingo!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章