Tuesday, June 28, 2022

[FIXED] How to resolve 'only connected graphs are supported' issue in ggraph in R?

Issue

I have a graph object, but when plotted using ggraph() using layout 'sparse_stress' (also tried other layouts), it is followed with the below error.

The min(degree) is 1. There are no disconnected nodes. What does the error mean by "only connected graphs are supported"?

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 Message

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


Solution

Min(degree)=1 means there are no disconnected nodes indeed, but there still might be disconnected graphs. See the graphlayouts README on github

Setting layout="sparse" should fix your problem if the graph is not too big.



Answered By - krltrl
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.