export function initGraphs()

in archive/src/app/GraphBuilder.js [9:53]


export function initGraphs(tokens, terms) {
  if(!tokens) return {
    root: null,
    graphs:[]
  };

  console.log('tokens', tokens);

  const entries = tokens.entries;
  const dbsize = tokens.computeSize();
  entries.forEach(function(t) {
    t.seqIndices = [];
    t.tokens.forEach(function(i) {return +i;});
  });
  console.log('dbsize = ' + dbsize);

  const minSupport = Math.max(dbsize * 0.001, 2);
  const maxSupport = dbsize / 3;

  const rootSeq = {
    words: [],
    newWord: null,
    graph: null,
    size: dbsize,
    DBs: entries
  };
  var graphs = [];

  var visibleGroups = expandSeqTree(rootSeq, graphs, defaultNodeCnt, minSupport, maxSupport, terms, tokens.itemset);

  graphs = graphs.filter(function(graph) {
    return graph.nodes.length > 2;
  }).slice(0, 10);

  const graphsFreq = updateNodesEdges(graphs, visibleGroups);

  return {
    root:rootSeq,
    graphs: graphs,
    minSupport,
    maxSupport,
    graphsFreqMax: graphsFreq.graphsFreqMax,
    graphsFreqMin: graphsFreq.graphsFreqMin,
  };
}