首页 > 解决方案 > 如何解决 R 中 ggraph 中的“仅支持连接图”问题?

问题描述

我有一个图形对象,但是当使用 ggraph() 使用布局'sparse_stress'(也尝试过其他布局)进行绘制时,它会出现以下错误。

min(degree) 为 1。没有断开的节点。“仅支持连接图”的错误是什么意思?

Subgraph_1994 = asIgraph(Subgraph_1994)

#sparse-stress gives error
ggraph(Subgraph_1994_Rev,layout="sparse_stress") + geom_edge_link() + geom_node_point() + theme_graph()

#also tried below but same error
ggraph(Subgraph_1994) + geom_edge_link() + geom_node_point() + theme_graph()

错误信息

Error in layout_with_sparse_stress(graph, pivots = pivots, weights = weights, : only connected graphs are supported.

标签: plotgraphigraphggraph

解决方案


Min(degree)=1 表示确实没有断开的节点,但仍然可能存在断开的。请参阅githubgraphlayouts上的README

layout="sparse"如果图表不是太大,设置应该可以解决您的问题。


推荐阅读