Commit c46c6ae6 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

sfdp_layout(): fix mu and gamma parameters

parent 7907bd2e
......@@ -205,6 +205,15 @@ static double f_r(double C, double K, double p, const Pos1& p1, const Pos2& p2)
return -C * pow(K, 1 + p) / pow(d, p);
}
template <class Pos1, class Pos2>
static double fs_r(double C, double l, const Pos1& p1, const Pos2& p2)
{
double d = dist(p1, p2);
if (d == 0)
return 0;
return -C * exp(-d/l);
}
template <class Pos1, class Pos2>
static double f_a(double K, const Pos1& p1, const Pos2& p2)
{
......@@ -361,9 +370,9 @@ void get_sfdp_layout(Graph& g, PosMap pos, VertexWeightMap vweight,
if (groups)
{
if (intra)
f = -f_r(mu, K, gamma, pos[v], get<0>(dleaf));
f = -fs_r(gamma, mu, pos[v], get<0>(dleaf));
else
f = f_r(mu, K, gamma, pos[v], get<0>(dleaf)) + f_r(C, K, p, pos[v], get<0>(dleaf));
f = fs_r(gamma, mu, pos[v], get<0>(dleaf)) + f_r(C, K, p, pos[v], get<0>(dleaf));
}
else
{
......@@ -399,9 +408,9 @@ void get_sfdp_layout(Graph& g, PosMap pos, VertexWeightMap vweight,
if (groups)
{
if (intra)
f = -f_r(mu, K, gamma, pos[v], cm);
f = -fs_r(gamma, mu, pos[v], cm);
else
f = f_r(mu, K, gamma, pos[v], cm) + f_r(C, K, p, pos[v], cm);
f = fs_r(gamma, mu, pos[v], cm) + f_r(C, K, p, pos[v], cm);
}
else
{
......
......@@ -559,8 +559,8 @@ def sfdp_layout(g, vweight=None, eweight=None, pin=None, groups=None, C=0.2,
Strength of attractive force between connected components.
gamma : float (optional, default: ``.3``)
Strength of the repulsive force between different groups.
mu : float (optional, default: ``3.0``)
Exponent of the strength of the repulsive force between different groups.
mu : float (optional, default: ``2``)
Typical length of the repulsive force between different groups.
kappa : float (optional, default: ``1.0``)
Multiplicative factor on the attracttive force between nodes of the same group.
init_step : float (optional, default: ``None``)
......@@ -655,6 +655,8 @@ def sfdp_layout(g, vweight=None, eweight=None, pin=None, groups=None, C=0.2,
if K is None:
K = _avg_edge_distance(g, pos)
mu *= K
if init_step is None:
init_step = 2 * max(_avg_edge_distance(g, pos), K)
......@@ -682,7 +684,7 @@ def sfdp_layout(g, vweight=None, eweight=None, pin=None, groups=None, C=0.2,
eweight=ecount if weighted_coarse else None,
groups=groups,
C=C, K=K, p=p,
theta=theta, gamma=gamma, mu=mu,
theta=theta, gamma=gamma, mu=mu, kappa=kappa,
epsilon=epsilon,
max_iter=max_iter,
cooling_step=cooling_step,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment