visualizer/actions.js
function tagNodesWithIds (data) {
  let id = 0
  const idsToNodes = new Map()
  const nodesToIds = new Map()
  tagNodes(data)

  return {
    idsToNodes,
    nodesToIds
  }

  function tag (node) {
    idsToNodes.set(id, node)
    nodesToIds.set(node, id)
    id++
  }
  function tagNodes (node) {
    tag(node)
    if (node.children) node.children.forEach(tagNodes)
  }
}
function tagNodesWithIds (data) {
  let id = 0
  const idsToNodes = new Map()
  const nodesToIds = new Map()
  tagNodes(data)

  return {
    idsToNodes,
    nodesToIds
  }

  function tag (node) {
    idsToNodes.set(id, node)
    nodesToIds.set(node, id)
    id++
  }
  function tagNodes (node) {
    tag(node)
    if (node.children) node.children.forEach(tagNodes)
  }
}
function tagNodesWithIds ( data ) { let id = 0 const idsToNodes = new Map ( ) const nodesToIds = new Map ( ) tagNodes ( data ) return { idsToNodes , nodesToIds } function tag ( node ) { idsToNodes . set ( id , node ) nodesToIds . set ( node , id ) id ++ } function tagNodes ( node ) { tag ( node ) if ( node . children ) node . children . forEach ( tagNodes ) } }
This just uses incrementing IDs but it will only be used for a single dataset, and it's deterministic enough for that
This just uses incrementing IDs but it will only be used for a single dataset and it s deterministic enough for that