score:2

Accepted answer

You are setting unnecessary attributes and don't need to use the findNodeIndex function either -- this is where the problem is. Some of the nodes are not being matched up correctly. You can simply write

data.forEach(function (link) {
            links.push({source: nodes[link.airportFrom] || (nodes[link.airportFrom] = {name: link.airportFrom}),
                        target: nodes[link.airportTo] || (nodes[link.airportTo] = {name: link.airportTo})});
        });

Complete example here.


Related Query

More Query from same tag