TL;DR
I need to set a graph's layout programmatically though JavaScript code.
Explanation
I have a graph in this format:
var graph = {
"nodes": [
{"x": 0, "y": 0},
{"x": 0, "y": 0},
{"x": 0, "y": 0},
{"x": 0, "y": 0},
],
"edges": [
{"source": 0, "target": 1},
{"source": 1, "target": 2},
{"source": 1, "target": 3},
{"source": 3, "target": 2},
]
};
All these nodes have an X and Y value of 0. If we draw this on canvas, the graph obviously won't look any good.
I want to apply an algorithm on this data-structure so that the X and Y values of all the nodes are auto-adjusted (with minimal edge crossings).
Existing solutions
I have tried force-directed layout of D3.js and some similar solutions. But they require too many iterations and most of my graphs have > 50 nodes with a lot of edges.
The algorithm I am looking for, should create a layout in minimal complexity and time (or it should be atleast faster than the iterative ones).
Matlab has three layout type engines for its biograph. LayoutTypeValue can be either hierarchical, radial and equilibrium. Radial seems like a good idea though.
Thanks.