[英]How to minimize the number of edge crossings with diagrammer, R?
When I plot a network graph with diagrammer, like the following toy example...当我使用制图器绘制网络图时,如下面的玩具示例...
library(DiagrammeR)
Dia <- function(edg, nodesd) {
nodes <- create_node_df( n=length(nodesd), label=nodesd,
width=0.3)
edges <- create_edge_df(from = edg$EveFrom, to = edg$EveTo,
rel = "leading_to")
graph <- create_graph( nodes_df = nodes, edges_df = edges)
render_graph(graph)
}
niv <- c("A","B","C","D","E","X","Y")
temp <- data.table(EveFrom=factor(c("A","A","A","A","B","C","D","E",
"X", "B"), levels=niv),
EveTo=factor(c("B","C","D","E","X","X","Y","Y","Y", "C"), levels=niv))
Dia(temp,niv)
How can I tell diagrammer to minimize the number of edge crossings automatically?我如何告诉制图师自动最小化边缘交叉的数量?
In this simple example if C and B positions were exchanged the result wouldn't have any edge crossing.在这个简单的例子中,如果 C 和 B 位置交换,结果不会有任何边缘交叉。 In more complex examples we cannot remove all crossings but at least minimize it.在更复杂的例子中,我们不能删除所有交叉,但至少可以将其最小化。
With visnetwork I can relocate the nodes使用 visnetwork 我可以重新定位节点
But it has other drawbacks, for example it doesn't let you export it as a vector graphic.但它还有其他缺点,例如它不允许您将其导出为矢量图形。
PD: This is the output with bergant solution (with labels hidden): PD:这是带有 bergant 解决方案的输出(隐藏标签):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.