GraphPlot.jl icon indicating copy to clipboard operation
GraphPlot.jl copied to clipboard

Adding Kamada Kawai layout

Open BCRARL opened this issue 6 years ago • 7 comments

I've written a simple implementation of the Kamada Kawai layout using Optim. Is there interest in a general inclusion? If so, I'll clean it up and put in a pull-request.

BCRARL avatar Jun 19 '19 14:06 BCRARL

Hi @BCRARL - does it require Optim.jl or other dependency? If so, we'd want to take a close look since we're trying not to explode the number of package dependencies in JuliaGraphs projects.

Thanks! Sorry for the delayed response.

sbromberger avatar Jul 31 '19 15:07 sbromberger

Yeah, it requires Optim for the optimization. Kamada Kawai solves a non-linear least squares problem. $$ \min_{x_i} \sum_{i,j} (\sqrt{\lVert x_i-x_j\rVert^2} - r_{ij})^2, $$ where $r_{ij}$ is the shortest path along the graph between vertices $i$ and $j$. In my opinion,

  • implementation of an optimizer is redundant and more error-prone than checking the dependency,
  • inlining the solver would negatively impact readability,
  • maintainability remains high since an optimization formulation is very general and should be portable across packages (a JuMP implementation would require very little rewriting for instance).

BCRARL avatar Jul 31 '19 15:07 BCRARL

Hi,

It's been a while since the last update. Is this layout will be added in GraphPlot? If not, is there an alternative package to add for Kamada Kawai layout?

atthom avatar May 11 '20 16:05 atthom

You can just use my fork, @atthom . I haven't kept up to date with the master branch, so some minor manual merging might be necessary. If you need me to update my kamada_kawai branch, let me know.

BCRARL avatar May 11 '20 17:05 BCRARL

I just merged all upstream changes, but I have not run any tests to see whether anything has broken in the meantime. If you run into an issue open it on my fork and I'll try to figure it out.

BCRARL avatar May 11 '20 17:05 BCRARL

Alright, thank you for the fast update.

atthom avatar May 11 '20 17:05 atthom

I actually developed something similar in the meantime, using Optim.jl. I have a significantly smaller implementation than you, though. I am sure there a lot missing but maybe there are a thing or two to take. https://gist.github.com/atthom/565f91aad416c400c280ed45b138123a

Constructive criticism is welcome :)

atthom avatar May 11 '20 19:05 atthom