Magnetron does 3 steps:
In general, attraction uses 1 / distance between points and cos(angle difference of attached line segments of points).
This demo here in addition explores global overlap between linestrings. Stefan suggested to use the overlap between buffered lines as an additional information.
To take overlap into account, we do the following:
If two lines are close together over their full length, the overlap weigth will be maximal (0.5). If they are long and only cross somewhere, the overlap weigth will be small compared to 0.5.