Hi I am trying to find the connected components of a simple weighted graph with edge weights having a value greater than zero as below.
using Graphs
using SimpleWeightedGraphs
len = 105_000
g = SimpleWeightedGraph(len)
idxs = []
for i in 1:25000
x = rand(1:len)
y = rand(1:len)
push!(idxs, x,y)
g.weights[x,y] = 1.0
g.weights[y,x] = 1.0
end
unique!(idxs)
cc = connected_components(g);
@time filter(c->(any(x->(x ∈ c), idxs)), cc)
The last line filter out connected components with edge weight greater than zero. But this is very expensive in terms of computational time and resource usage for huge graphs. Is there any optimised way to do the same?