我正在尝试创建一个弧形图,显示非营利组织之间的关系,重点是以其中一个非营利组织为中心的子图。这个子图中有这么多的非营利组织,我需要减少弧图中的节点数量,只关注最强的连接。
我已成功过滤掉权重低于 50 的边。但是当我创建图表时,即使边消失了,节点仍然存在。如何从弧形图中过滤掉不需要的节点?
这是我的代码,从 igraph 对象的创建开始。
# Create an igraph object
NGO_igraph <- graph_from_data_frame(d = edges, vertices = nodes, directed = TRUE)
# Create a subgraph centered on a node
# Start by entering the node ID
nodes_of_interest <- c(48)
# Build the graph
selegoV <- ego(NGO_igraph, order=1, nodes = nodes_of_interest, mode = "all", mindist = 0)
selegoG <- induced_subgraph(NGO_igraph,unlist(selegoV))
# Reducing the graph based on edge weight
smaller <- delete.edges(selegoG, which(E(selegoG)$weight < 50))
# Plotting an arc graph
ggraph(smaller, layout = "linear") +
geom_edge_arc(aes(width = weight), alpha = 0.8) +
scale_edge_width(range = c(0.2, 2)) +
geom_node_text(aes(label = label)) +
labs(edge_width = "Interactions") +
theme_graph()