在图形工具中仅绘制最大的连通子图

Draw only biggest connected subgraph in graph-tool

在graph-tool中,有没有办法只绘制最大的连通子图?我目前有一个大的连接子图和一些我不是特别感兴趣的较小的连接子图。我不确定如何在绘制子图之前找到它们,所以如果有 graph_tool.

如果有帮助,这是来源:https://github.com/jvdheyden/DBS/blob/master/projekt/phase3/main.py

您可以使用GraphView筛选出最大的组件,然后绘制它。

import graph_tool.all as gt

# Load a disconnected graph
g = gt.collection.data["netscience"]

# Extract the largest component
largest_comp = gt.GraphView(g, vfilt = gt.label_largest_component(g))

# Draw the largest component
gt.graph_draw(largest_comp, output = "largest_comp.svg")

这样,您就不会丢失整个图形,以备绘制后需要。