function updateNodesEdges()

in src/models/SentenTreeModel.js [156:181]


function updateNodesEdges(graphs, leafSeqs) {
  leafSeqs
    .filter(seq => graphs.indexOf(seq.graph) >= 0)
    .forEach(seq => {
      const words = seq.words;
      const linkadj = seq.graph.linkadj;
      // printSeq(seq);
      for (let i = 0; i < words.length - 1; i++) {
        const word = words[i];
        const id = word.id;
        const nextId = words[i + 1].id;

        if (!(id in linkadj)) linkadj[id] = {};

        if (nextId in linkadj[id]) {
          linkadj[id][nextId] += seq.size;
        } else {
          linkadj[id][nextId] = seq.size;
        }
      }

      words
        .filter(word => !word.leafSeq || word.leafSeq < seq.size)
        .forEach(word => { word.leafSeq = seq; });
    });
}