eMap.has(l.source) && nodeMap.has(l.target))

    // Count link per node (for computing remaining link count)
    nodes.forEach(n => { n.linkCount = 0 })
    links.forEach(l => {
      nodeMap.get(l.source).linkCount++
      nodeMap.get(l.target).linkCount++
    })

    // Align preset nodes to x-axis
    preset.selected.forEach(id => {
      const n = nodeMap.get(id)
      if (n !== undefined) {
        n.fy = n.y = 0
      }
    })
  }).catch(err => {
    console.log(err)
  })
}

function main () {
  upda