graph-theory - 使用具有命名顶点的边创建 Mathematica/Combinatorica 图

标签 graph-theory wolfram-mathematica

如何从具有命名顶点的边创建 Mathematica 图?例如:

http://pastebin.com/Se1Nhe3M

我已经尝试了上面的几种变体,但是 Combinatorica 从来没有 挺接受的吧。显然,Graph[] 想要坐标 位置,我希望 Combinatorica 自己弄清楚。

将顶点添加到 EmptyGraph[0](或其他)也失败了。

GraphUtilities 不是一个选项,因为我想做相当复杂的事情 分析我的图表。

这似乎是一个简单的问题。 Graphviz 轻松创建图表 带有命名顶点的边,所以我确定 Mathematica 也可以吗?

我读过:

ShowGraph[ { {e1,e2}, {e1, e3} }, {e1,e2,e3} ]; // what is the problem here?

但这似乎对我的具体情况没有帮助。

最佳答案

如果您有 Mathematica 7,试试内置的 GraphPlot :

GraphPlot[{"Conga" -> "Egypt", "Egypt" -> "Conga", 
  "Conga" -> "Sarah Desert", "Sarah Desert" -> "Conga", 
  "Egypt" -> "Europe", "Europe" -> "Egypt", "Egypt" -> "Arabia", 
  "Arabia" -> "Egypt", "Egypt" -> "Sarah Desert", 
  "Sarah Desert" -> "Egypt", "UK" -> "Europe", "Europe" -> "UK", 
  "UK" -> "Iceland", "Iceland" -> "UK", "UK" -> "Greenland", 
  "Greenland" -> "UK", "Europe" -> "Arabia", "Arabia" -> "Europe", 
  "Europe" -> "Germany", "Germany" -> "Europe", "Europe" -> "Iceland",
   "Iceland" -> "Europe", "Europe" -> "Sarah Desert", 
  "Sarah Desert" -> "Europe", "Germany" -> "Russia", 
  "Russia" -> "Germany", "Germany" -> "Arabia", "Arabia" -> "Germany",
   "Germany" -> "Iceland", "Iceland" -> "Germany", 
  "Germany" -> "Irakistan", "Irakistan" -> "Germany", 
  "Austr(al)ia" -> "China", "China" -> "Austr(al)ia", 
  "Arabia" -> "Irakistan", "Irakistan" -> "Arabia", 
  "Canada" -> "More Russia", "More Russia" -> "Canada", 
  "Canada" -> "USA", "USA" -> "Canada", 
  "Canada" -> "Andy's Mountains", "Andy's Mountains" -> "Canada", 
  "More Russia" -> "Russia", "Russia" -> "More Russia", 
  "More Russia" -> "China", "China" -> "More Russia", 
  "More Russia" -> "Irakistan", "Irakistan" -> "More Russia", 
  "China" -> "Irakistan", "Irakistan" -> "China", 
  "USA" -> "Greenland", "Greenland" -> "USA", 
  "USA" -> "Andy's Mountains", "Andy's Mountains" -> "USA", 
  "Brazil" -> "Sarah Desert", "Sarah Desert" -> "Brazil", 
  "Brazil" -> "Andy's Mountains", "Andy's Mountains" -> "Brazil", 
  "Russia" -> "Irakistan", "Irakistan" -> "Russia"}, 
 DirectedEdges -> True]

这将为您提供以下内容,例如:

alt text http://img638.imageshack.us/img638/7803/plotm.png

布局、顶点和边缘标签和样式等有很多选项。

关于graph-theory - 使用具有命名顶点的边创建 Mathematica/Combinatorica 图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3420697/

相关文章:

algorithm - 最小化二维坐标映射的快速算法

wolfram-mathematica - Mathematica 中的统计股票扫描仪

wolfram-mathematica - 美元符号 $ 在内部有什么用?

wolfram-mathematica - 如何最大化 Mathematica 中将可变长度列表作为输入的函数?

algorithm - 给定食谱列表和拥有的成分列表,哪种算法最适合确定 "Which ingredient could I add to access the most recipes?"

algorithm - Prim 算法和 MST

wolfram-mathematica - 交集或求解

wolfram-mathematica - 在 Mathematica 中安全地设置 "struct"

python - 如何将顶点前驱数据帧转换为路径?

algorithm - 小度有向无环图中的最短路径