2010-12-06 8 views
2

私はs'Graphc'GraphSystem'GraphCombinatorica'Graph(とCombinatoricaと競合する他の機能)を参照することができるようにしたいと思いますか?サイモンのアイデア後コンテキストパスのエイリアスを作成しますか?

は、以下の

{Set @@ {ToExpression["c" <> Last[StringSplit[#, "`"]]], 
     ToExpression[#]}} & /@ Names["Combinatorica`*"]; 
{Set @@ {ToExpression["s" <> Last[StringSplit[#, "`"]]], 
     ToExpression[#]}} & /@ Names["System`*"]; 

cCompleteGraph[5]sCompleteGraph[5]リターンCombinatoricaと今後の参考のために、それぞれ

更新月8日 Systemグラフを動作しているようですが、これは私が終わった方法がありますGraphUtilities,Combinatoricaと組み込みのグラフ機能を一緒に使用します。これは、すべての呼び出しでCombinatorica$ContextPathに追加するので、Graphのようなすべてのcombinatorica関数をcGraphに再マッピングし、$Postを変更して、各評価でContextPathからGraphUtilitiesとCombinatoricaを削除する必要があります。

要約すると、各セッションの開始時に以下のコードを実行します。もちろん

$PreRead = # /. {str_String :> 
    StringReplace[ 
     str, {RegularExpression["^s`(.*)"] :> "System`" <> "$1", 
     RegularExpression["^c`(.*)"] :> "Combinatorica`" <> "$1"}]} & 

、これは非常に低いレベルで働いているので、取る:Combinatoricaのfuncは今cfuncで、GraphUtilitiesのfuncがちょうどfunc

Needs["Combinatorica`"]; 
combNames = Names["Combinatorica`*"]; 
{Set @@ {ToExpression["c" <> Last[StringSplit[#, "`"]]], 
     ToExpression[#]}} & /@ Names["Combinatorica`*"]; 
Needs["GraphUtilities`"]; 
$ContextPath = DeleteCases[$ContextPath, "Combinatorica`"]; 
$Post = ($ContextPath = 
    DeleteCases[$ContextPath, 
     "Combinatorica`" | "GraphUtilities`"]; #) &; 
+0

いくつのシンボルが必要ですか? cGraph = Combinatorica'Graph(そして、$ ContextPathのCombinatoricaを保つ)を実行することは実現可能でしょうか? – Janus

+0

これはv8のことですか?私のv7システムでは、 'Intersection @@(Names [#<>" \ '*"]&/ @ {"Combinatorica"、 "System"}) 'は空のリストを返します。 – Janus

+0

うん、バージョン8、今は2つのタイプのグラフオブジェクトがあります。WRIがCombinatoricaの機能を組み込み関数に置き換えるようです。 –

答えて

2

何かのようにGraphUtilities'func、および内蔵のFUNCされていますお手入れ。

+0

これは 'StringReplace :: strse:StringReplace [{2、+、5}]、{ Combinatorica '<> $ 1}]。 ' –

+0

" c'CompleteGraph [5] "と思われます。 $ PreReadに渡す前に "RowBox [List [" c'CompleteGraph "、" [5 "、"] "]]"に変わります。 –

+0

@Yaroslav:今修正されました。それは私がシンボル上でしかテストするのではなく、より一般的な表現ではないからです。 (したがって、$ PreReadを使用するときに気をつけるコメント:-) –

関連する問題