On his d3 Sankey Diagram page, Mike Bostock says "The algorithm could be improved in the future, say to minimize link crossing".
I would like to invest some time and do just that, but I'm not sure were to begin. Does anyone have any propositions or ideas as to how to achieve this?
My intuition is that the iterative relaxation applied on nodes to minimize link distances could also be used to reposition the same nodes to minimize link crossing.
I really need to 'spread out' the nodes vertically even in situations where there is only one node per x-position, in such a way that link crossings are strongly reduced (it doesn't need to be an academic-level result, a practical, better-than-it-is-right-now-result will suffice)
Here is a JS Fiddle as a starting point - with nodes positioned in a suboptimal way that makes edges/links cross from the very beginning:
function getData() {
return {
"nodes": [{
"node": 0,
"name": "Name0"
}, {
"node": 1,
"name": "Name1"
}, {
"node": 2,
"name": "Action2"
}, {
"node": 3,
"name": "Name3"
}, {
"node": 4,
"name": "Name4"
}, {
"node": 5,
"name": "Action5"
}, {
"node": 6,
"name": "Action6"
}, {
"node": 7,
"name": "Action7"
}, {
"node": 8,
"name": "Action8"
}],
"links": [{
"source": 0,
"target": 6,
"value": 25,
"id": "name0"
}, {
"source": 1,
"target": 2,
"value": 25,
"id": "Name1"
}, {
"source": 2,
"target": 5,
"value": 25,
"id": "Name1"
}, {
"source": 3,
"target": 6,
"value": 25,
"id": "Name3"
}, {
"source": 6,
"target": 7,
"value": 25,
"id": "name0"
}, {
"source": 4,
"target": 7,
"value": 25,
"id": "Name4"
}, {
"source": 5,
"target": 7,
"value": 25,
"id": "Name1"
}, {
"source": 6,
"target": 7,
"value": 25,
"id": "Name3",
}, {
"source": 7,
"target": 8,
"value": 25,
"id": "Name3"
}]
};
}