This is a demo for the use of the local clustering code.
In [1]:
using Laplacians
First, a small example
In [2]:
a = chimera(100, 3);
In [3]:
s = prn(a, [1,2,3], 0.2, 5);
conds = compConductance(a, s)
println(conds, " ", length(s))
In [4]:
minEpsSigma = getVolume(a, s) / getVolume(a, setdiff(collect(1:max(a.n, a.m)), s));
cut, flow = localImprove(a, s, epsSigma = minEpsSigma);
condcut = compConductance(a, cut)
println(concut, " ", length(cut))
Out[4]:
If maxSize isn't set, the new conductance is always better than the initial one. In some cases much better.
Now a larger example
In [5]:
a = chimera(1000000, 1);
In [6]:
s = prn(a, [1,2,3], 0.5, 5);
conds = compConductance(a, s)
println(conds, " ", length(s))
In [7]:
minEpsSigma = getVolume(a, s) / getVolume(a, setdiff(collect(1:max(a.n, a.m)), s));
cut, flow = localImprove(a, s, epsSigma = minEpsSigma, maxSize = 10000);
condcut = compConductance(a, cut)
println(condcut, " ", length(cut))
There are however cases where we don't get any improvements, even if our maxSize value is set to something sensibly larger. This is mainly because of the structure of the graphs we are working with. The process can be hit & miss.
In [8]:
a = chimera(1000000, 2);
In [9]:
s = prn(a, [1,2,3], 0.5, 5);
conds = compConductance(a, s)
println(conds, " ", length(s))
In [10]:
minEpsSigma = getVolume(a, s) / getVolume(a, setdiff(collect(1:max(a.n, a.m)), s));
cut, flow = localImprove(a, s, epsSigma = minEpsSigma, maxSize = 100000);
condcut = compConductance(a, cut)
println(condcut, " ", length(cut))
We can however try a refinind heuristic to get a slight improvement on our result.
In [11]:
heur = refineCut(a, cut)
condref = compConductance(a, heur)
println(condref, " ", length(heur))