-
Notifications
You must be signed in to change notification settings - Fork 263
Closed as not planned
Description
报错,segmentation fault,下面是代码,错误出现max_independent_set = G.largest_independent_vertex_sets()[0],直接报错了
unique_vertices = set()
edges = []
map_data: dict[str, str] = {}
filename = 'graph_data.txt'
# 使用 igraph 创建无向图
G = ig.Graph()
with open(filename, "rb") as f:
for line in f:
# 使用 .strip() 可以去掉每行末尾的换行符和其他空白字符
content = line.strip()
json_data = json.loads(content)
if json_data["uuid_1"] not in map_data:
map_data[json_data["uuid_1"]] = json_data["origin_uuid_1"]
if json_data["uuid_2"] not in map_data:
map_data[json_data["uuid_2"]] = json_data["origin_uuid_2"]
unique_vertices.add(json_data["uuid_1"])
unique_vertices.add(json_data["uuid_2"])
edges.append((json_data["uuid_1"], json_data["uuid_2"]))
if len(edges) < 1000:
continue
G.add_vertices(list(unique_vertices))
G.add_edges(edges)
unique_vertices.clear()
edges.clear()
if len(edges) > 0:
G.add_vertices(list(unique_vertices))
G.add_edges(edges)
unique_vertices.clear()
edges.clear()
# 获取最大独立集
max_independent_set = G.largest_independent_vertex_sets()[0]
print(f"max_independent_set len: {len(max_independent_set)}")
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels