我想自動確定給定的對象是Combinatorica還是Mathematica 8.0 Graph。在Mathematica中分辨不同的「圖形」對象8
它似乎並不認爲FullForm有足夠的信息來分辨出哪個是
(* output of Combinatorica`CompleteGraph[1] *)
Graph[List[],List[List[List[0,0]]]]
(* output of System`CompleteGraph[1] *)
Graph[List[1],List[]]
數學,但是,能夠告訴他們分開,並呈現一個爲文本字符串,另一個視覺對象。有
- 的方式來查看錶達式中「隱藏」的信息並不在FullForm顯示
- 方式來看待Mathematica使用渲染表達式的規則?
更新: 看來頭給出了兩個圖不同的結果,即使顯示的頭是相同的。定義函數爲f [a_System'Graph]和f [a_Combinatorica'Graph]導致正確的版本被稱爲
Head [g] ===圖可以表示根據$ ContextPath的System'Graph或Combinatorica'Graph。某些功能會自動將「Combinatorica」添加到上下文路徑。一種解決方案是檢查「Combinatorica」是否處於上下文路徑中並將其刪除,不知道它是多麼健壯 – 2010-12-11 23:21:00
好吧,它看起來像是一個顯示問題,你是對的,即使它們可能在FullForm中顯示相同 – 2010-12-11 23:40:27