gpt4 book ai didi

graph - 在数学中。在 GraphPlot 中使用图像作为顶点时,如何防止图像重叠?

转载 作者:行者123 更新时间:2023-12-04 12:42:43 25 4
gpt4 key购买 nike

我正在使用 GraphPlot绘制大约有 100 个顶点的有向图。我通过定义 VertexRenderingFunction 用一个小的矩形或方形图像替换每个顶点。图像经常重叠。有没有办法让 Mathematica 将顶点间隔得更远以防止它们重叠?

我已经尝试了“方法”的各种明显选项(“SpringElectricalEmbedding”、“SpringEmbedding”、“HighDimensionalEmbedding”、“CircularEmbedding”、“RandomEmbedding”、“LinearEmbedding”)。

trans = {1 -> 1, 2 -> 1, 3 -> 1, 4 -> 1, 5 -> 1, 6 -> 1, 7 -> 1,
8 -> 1, 9 -> 1, 10 -> 1, 11 -> 1, 12 -> 1, 13 -> 1, 14 -> 1,
15 -> 1, 16 -> 1, 17 -> 1, 18 -> 13, 19 -> 1, 20 -> 13, 21 -> 13,
22 -> 70, 23 -> 1, 24 -> 1, 25 -> 1, 26 -> 1, 27 -> 13, 28 -> 13,
29 -> 1, 30 -> 13, 31 -> 13, 32 -> 1, 33 -> 19, 34 -> 70, 35 -> 70,
36 -> 1, 37 -> 1, 38 -> 1, 39 -> 39, 40 -> 13, 41 -> 2, 42 -> 13,
43 -> 1, 44 -> 2, 45 -> 1, 46 -> 52, 47 -> 2, 48 -> 68, 49 -> 49,
50 -> 19, 51 -> 78, 52 -> 1, 53 -> 1, 54 -> 39, 55 -> 13, 56 -> 56,
57 -> 13, 58 -> 13, 59 -> 1, 60 -> 36, 61 -> 1, 62 -> 52, 63 -> 2,
6 4 -> 68, 65 -> 19, 66 -> 56, 67 -> 4, 68 -> 76, 69 -> 19,
70 -> 78, 71 -> 1, 72 -> 39, 73 -> 52, 74 -> 56, 75 -> 23,
76 -> 76, 77 -> 56, 78 -> 78};

image = {{1, 0, 0, 0, 0}, {0, 1, 0, 0, 0}};

GraphPlot[trans, DirectedEdges -> True, VertexLabeling -> True,
VertexRenderingFunction -> (Inset[
ArrayPlot[image, ImageSize -> 15, Mesh -> True], #1] &)]

Output

最佳答案

编辑 [我重新开始,根据你给出的例子]:

使用您的 transimage你可以试试:

p = ArrayPlot[image, ImageSize -> 35, Mesh -> True];

Graph[trans, DirectedEdges -> True, VertexLabels -> Placed[p, Tooltip],
ImagePadding -> 10, ImageSize -> 500]

当您将鼠标悬停在每个顶点上时,图像将出现在工具提示中。如果你愿意,你可以为不同的顶点标签使用不同的图像;只需使用规则列表。

下图显示了它的样子(没有工具提示)。
点击 link看看它是如何与工具提示一起工作的。

graph

关于graph - 在数学中。在 GraphPlot 中使用图像作为顶点时,如何防止图像重叠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8926071/

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