【发布时间】:2010-11-29 08:04:02
【问题描述】:
有没有人想出在 Mathematica 8 中修改 Graph 对象的方法?特别是,如何获得与右键单击图表时相同的功能。
一些新的图形函数与
Combinatorica冲突,有没有办法强制 Mathematica 使用该函数的内置版本?换句话说,有没有办法在我执行Needs["Combinatorica"]之后访问内置的CompleteGraph,它导入了CompleteGraph的Combinatorica 版本?
为了澄清 1,Graph 上的上下文菜单可让您更改 GraphStyle 和 GraphLayout,我希望能够以编程方式更改它们。这是我发现更改 Graph 对象的 GraphStyle 的一种方法
g = GridGraph[{4, 4}];
BooleanGraph[Or, g, g, GraphStyle -> "DiagramBlack"]
但是,这会忘记原始图形的选项,例如 VertexCoordinates
在网格图上尝试 Brett 的配方
g = GridGraph[{3, 2}, ImageSize -> Tiny]
coords = PropertyValue[{g, #}, VertexCoordinates] & /@ VertexList[g];
Graph[EdgeList[g], GraphStyle -> "BasicGold",
VertexCoordinates -> coords, ImageSize -> Tiny]
(来源:yaroslavvb.com)
Mathematica 如何处理图形操作中的图形坐标似乎存在错误。下面的第一行置换坐标,第二行给出内部警告,可能与坐标有关。对每个顶点使用非整数顶点和显式坐标没有帮助。一种解决方案是全局存储坐标并具有fixCoordinates 功能,以便在修改后将正确的坐标重新分配给Graph
VertexDelete[GridGraph[{3, 3}], 1]
NeighborhoodGraph[VertexDelete[GridGraph[{3, 3}], 1], 2]
【问题讨论】:
-
回复。 2.: System`CompleteGraph?
-
Re#2,您可以从上下文路径中删除 Combinatorica -- 然后使用显式完整路径引用所有 Combinatorica 函数...
-
如何从上下文路径中删除?
-
$ContextPath = DeleteCases[$ContextPath, "Combinatorica`"]