当我用图表绘制器绘制网络图时,就像下面的玩具示例......
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)
我如何告诉制图师自动最小化边缘交叉的数量?
在这个简单的示例中,如果交换 C 和 B 位置,则结果不会有任何边缘交叉。在更复杂的示例中,我们不能删除所有交叉点,但至少可以将其最小化。
使用 visnetwork 我可以重新定位节点
但它还有其他缺点,例如它不允许您将其导出为矢量图形。