作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在Mathematica 8中,有没有简单的方法可以执行以下操作?
Graph
或
GraphPlot
的显示。
最佳答案
这是在MMA 8.0中更改图形的两种基本方法。第一个依赖于HighlightGraph
,尤其是GraphHighlightStyle -> "DehighlightHide"
。第二种方法在该图的 future 变体中使用该图的VertexCoordinates。
我们将分别讨论删除和添加,因为它们涉及的方法略有不同。
[P.S. :我对答案进行了几处编辑,以使其更清楚。]
首先是一些数据:
edges={1\[UndirectedEdge]8,1\[UndirectedEdge]11,1\[UndirectedEdge]18,1\[UndirectedEdge]19,1\[UndirectedEdge]21,1\[UndirectedEdge]25,1\[UndirectedEdge]26,1\[UndirectedEdge]34,1\[UndirectedEdge]37,1\[UndirectedEdge]38,4\[UndirectedEdge]11,4\[UndirectedEdge]12,4\[UndirectedEdge]26,4\[UndirectedEdge]27,4\[UndirectedEdge]47,4\[UndirectedEdge]56,4\[UndirectedEdge]57,4\[UndirectedEdge]96,4\[UndirectedEdge]117,5\[UndirectedEdge]11,5\[UndirectedEdge]18,7\[UndirectedEdge]21,7\[UndirectedEdge]25,7\[UndirectedEdge]34,7\[UndirectedEdge]55,7\[UndirectedEdge]76,8\[UndirectedEdge]11,26\[UndirectedEdge]29,26\[UndirectedEdge]49,26\[UndirectedEdge]52,26\[UndirectedEdge]111,27\[UndirectedEdge]28,27\[UndirectedEdge]51,42\[UndirectedEdge]47,49\[UndirectedEdge]97,51\[UndirectedEdge]96}
g = Graph[edges, VertexLabels -> "Name", ImagePadding -> 10,
ImageSize -> 500]
remainingEdgesAndVertices
包含所有顶点和初始边,但边(4,11)除外。
remainingEdgesAndVertices =
Join[VertexList[g], Complement[EdgeList[g], {4 \[UndirectedEdge] 11}]]
HighlightGraph[g, remainingEdgesAndVertices, VertexLabels -> "Name",
ImagePadding -> 10, GraphHighlightStyle -> "DehighlightHide",
ImageSize -> 500]
Graph[Complement[edges, {4 \[UndirectedEdge] 11}],
VertexLabels -> "Name", ImagePadding -> 10, ImageSize -> 500]
g2 = Graph[Append[edges, 42 \[UndirectedEdge] 37],
VertexLabels -> "Name", ImagePadding -> 10, ImageSize -> 500]
HighlightGraph[g2,
Join[Complement[EdgeList[g2], {42 \[UndirectedEdge] 37}],
VertexList[g2]], VertexLabels -> "Name", ImagePadding -> 10,
GraphHighlightStyle -> "DehighlightHide"]
VertexCoordinates
中:
vc = VertexCoordinates ->
Append[AbsoluteOptions[g2, VertexCoordinates][[2]], {0, 0}]
g3 = Graph[Append[EdgeList [g2], 4 \[UndirectedEdge] 999], vc,
VertexLabels -> "Name", ImagePadding -> 10,
GraphHighlightStyle -> "DehighlightHide", ImageSize -> 500]
VertexCoordinates
即可。
VertexCoordinates
)从图形中删除边。
关于wolfram-mathematica - 稍作修改后重新布局图,同时保留原始布局的特征,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6550127/
我是一名优秀的程序员,十分优秀!