跳到内容

将多个图放置在同一布局上

用法

merge_coords(graphs, layouts, method = "dla")

layout_components(graph, layout = layout_with_kk, ...)

参数

graphs

图对象列表。

layouts

两列矩阵列表。

method

字符常量,指定要使用的方法。目前只实现了 dla

graph

输入图。

layout

函数对象,要使用的布局函数。

...

传递给 layout 布局函数的其他参数。

一个矩阵,包含两列,行数等于图中顶点的总数。

详细信息

merge_coords() 接收一个图列表和一个坐标列表,并将这些图放置在一个共同的布局中。使用 method 参数选择使用的方法,但目前只实现了 dla 方法。

dla 方法用圆圈覆盖图。然后,它首先根据顶点数量对图进行排序,并将最大的图放置在布局的中心。然后,其他图以递减的顺序通过 DLA(扩散限制聚集)算法放置:该图随机放置在一个远离中心的圆圈上,并进行随机游走,直到该图走入已放置的较大图中,或走得离布局中心太远。

layout_components() 函数首先将图分解为最大的连通分量,并为每个分量单独调用提供的 layout 函数。最后,它通过调用 merge_coords() 合并布局。

作者

Gabor Csardi csardi.gabor@gmail.com

示例


# create 20 scale-free graphs and place them in a common layout
graphs <- lapply(sample(5:20, 20, replace = TRUE),
  barabasi.game,
  directed = FALSE
)
layouts <- lapply(graphs, layout_with_kk)
lay <- merge_coords(graphs, layouts)
g <- disjoint_union(graphs)
plot(g, layout = lay, vertex.size = 3, labels = NA, edge.color = "black")