gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 05:11:57 27 4
gpt4 key购买 nike

如何从具有命名顶点的边创建 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com