Calculate score of specified node.
@param node
@param candidates
191626
function calculateNodeScore (node, candidates) {
  const txt = node.text()
  let contentScore = 1

  // Ignore too small nodes
  if (txt.length < 25) {
    return
  }

  // Add points for any commas within this paragraph support Chinese commas
  const commas = txt.match(/[,，.。;；?？、]/g)
  if (commas && commas.length) {
    contentScore += commas.length
  }

  // For every 100 characters in this paragraph, add another point. Up to 3 points.
  contentScore += Math.min(Math.floor(txt.length / 100), 3)

  // If it has an article parent
  if (node.closest('article')) {
    contentScore += 25
  }

  // Initialize Parent and Grandparent
  // First initialize the parent node with contentScore / 1, then grandParentNode with contentScore / 2
  const parent = node.parent()

  if (parent && parent.length > 0) {
    scoreCandidate(parent, contentScore, candidates)
    const grandParent = parent.parent()
    if (grandParent && grandParent.length > 0) {
      scoreCandidate(grandParent, contentScore / 2, candidates)
    }
  }
}
422627
public static void computePositions(Node node, int depth, double aoff, double awid, int maxdepth) {
    double r = depth / (maxdepth - 1.);
    node.x = FastMath.sin(aoff + awid * .5) * r;
    node.y = FastMath.cos(aoff + awid * .5) * r;

    double cpos = aoff;
    double cwid = awid / node.weight;
    for(Node c : node.children) {
      computePositions(c, depth + 1, cpos, cwid * c.weight, maxdepth);
      cpos += cwid * c.weight;
    }
  }
576544
public int getNodeIndex(final Node node) {
        for (int i = 0; i < nodeList.size(); i++) {
            if (nodeList.get(i).equals(node)) {
                return i;
            }
        }
        return -1;
    }
615958
private void computeWeights(Node node) {
    int wsum = 0;
    for(Node child : node.children) {
      computeWeights(child);
      wsum += child.weight;
    }
    node.weight = Math.max(1, wsum);
  }
523982
public void selectAndReveal(INode node) {
		int[] offsetLength = this.locationSearcher.getNodeOffset(node);
		selectAndReveal(offsetLength[0], offsetLength[1]);
	}
1080195
public void calcScore()
  {

    if ((getPredicateCount() > 0) || (null != m_relativePathPattern))
    {
      m_score = SCORE_OTHER;
    }
    else
      super.calcScore();

    if (null == m_targetString)
      calcTargetString();
  }
162364
public void addNode(Node node) {

		long nId = node.getId();
		
		if (this.containsNode(nId))
			throw new DuplicatedNodeException(nId);
		int index = nextNodeId++;
		nodeIdMapping.put(nId, index);

		int aliveIndex = index >> 5;
		int aliveSubIndex = index & 31;

		if (aliveIndex >= aliveNodes.size())
			aliveNodes.add(0);

		aliveNodes.set(aliveIndex, aliveNodes.get(aliveIndex) | (byte)(1 << aliveSubIndex));

		adjacency.add(new IntHashSet[] {new IntHashSet(), new IntHashSet()});

		nodes.add(node);
		numberOfNodes++;
	}
1361909
protected void scoreAllTrees(double[] row, double[] preds) {
        java.util.Arrays.fill(preds, 0);
        scoreTreeRange(row, 0, _ntree_groups, preds);
    }
100570
public void characters(org.w3c.dom.Node node)
        throws org.xml.sax.SAXException
    {
        // remember the current node
        if (m_state != null)
        {
            m_state.setCurrentNode(node);
        }
        
        // Get the node's value as a String and use that String as if
        // it were an input character notification.
        String data = node.getNodeValue();
        if (data != null) {
            this.characters(data);
        }
    }
85435
public static <S extends Sequence<S>> int calculateScore(S seq1, Range seq1Range, Mutations<S> mutations,
                                                             LinearGapAlignmentScoring<S> scoring) {
        if (!mutations.isEmpty() && mutations.getPositionByIndex(0) < seq1Range.getFrom() - 1)
            throw new IllegalArgumentException();

        final AlignmentIteratorForward<S> iterator = new AlignmentIteratorForward<>(mutations, seq1Range);

        int score = 0;

        while (iterator.advance()) {
            final int mut = iterator.getCurrentMutation();
            switch (Mutation.getRawTypeCode(mut)) {
                case RAW_MUTATION_TYPE_SUBSTITUTION:
                    score += scoring.getScore(Mutation.getFrom(mut), Mutation.getTo(mut));
                    break;

                case RAW_MUTATION_TYPE_DELETION:
                case RAW_MUTATION_TYPE_INSERTION:
                    score += scoring.getGapPenalty();
                    break;

                default:
                    byte c = seq1.codeAt(iterator.getSeq1Position());
                    score += scoring.getScore(c, c);
                    break;
            }
        }

        return score;
    }
434155
public static void insideAlgorithmFirstOrderExpect(final Hypergraph graph, final HyperpotentialFoe w,
            final Algebra s, final Scores scores) {
        final int n = graph.getNodes().size();
        final double[] beta = new double[n];
        final double[] betaFoe = new double[n];
        // \beta_i = 0 \forall i
        Arrays.fill(beta, s.zero());
        Arrays.fill(betaFoe, s.zero());
        graph.applyTopoSort(new HyperedgeFn() {

            @Override
            public void apply(Hyperedge e) {
                // \beta_{H(e)} += w_e \prod_{j \in T(e)} \beta_j
                double prod = s.one();
                double prodFoe = s.zero();
                for (Hypernode jNode : e.getTailNodes()) {
                    int j = jNode.getId();
                    // prod = s.times(prod, beta[j]);
                    // prodFoe = s.plus(s.times(prod, betaFoe[j]), s.times(beta[j], prodFoe));
                    double p1 = prod;
                    double p2 = beta[j];
                    double r1 = prodFoe;
                    double r2 = betaFoe[j];
                    prod = s.times(p1, p2);
                    prodFoe = s.plus(s.times(p1, r2), s.times(p2, r1));
                }
                // prod = s.times(prod, w.getScore(e, s));
                // prodFoe = s.plus(s.times(prod, w.getScoreFoe(e, s)), s.times(w.getScore(e, s), prodFoe));
                double p1 = prod;
                double p2 = w.getScore(e, s);
                double r1 = prodFoe;
                double r2 = w.getScoreFoe(e, s);
                prod = s.times(p1, p2);
                prodFoe = s.plus(s.times(p1, r2), s.times(p2, r1));
                
                int i = e.getHeadNode().getId();
                //if (log.isTraceEnabled()) { log.trace(String.format("old beta[%d] = %f",  i, s.toReal(beta[i]))); }
                beta[i] = s.plus(beta[i], prod);
                betaFoe[i] = s.plus(betaFoe[i], prodFoe);
                assert !s.isNaN(beta[i]);
                assert !s.isNaN(betaFoe[i]);
                // log.debug(String.format("%s w_e=%f beta[%d] = %.3f betaFoe[%d] = %.3f", e.getLabel(), s.toReal(w.getScore(e, s)), i, s.toReal(beta[i]), i, s.toReal(betaFoe[i]))); 
            }
            
        });
        scores.beta = beta;
        scores.betaFoe = betaFoe;
    }
1174777
public int complete(final String buffer, final int cursor, final List<CharSequence> candidates) {
        // buffer could be null
        checkNotNull(candidates);

        List<Completion> completions = new ArrayList<Completion>(completers.size());

        // Run each completer, saving its completion results
        int max = -1;
        for (Completer completer : completers) {
            Completion completion = new Completion(candidates);
            completion.complete(completer, buffer, cursor);

            // Compute the max cursor position
            max = Math.max(max, completion.cursor);

            completions.add(completion);
        }

        SortedSet<CharSequence> allCandidates = new TreeSet<>();

        // Append candidates from completions which have the same cursor position as max
        for (Completion completion : completions) {
            if (completion.cursor == max) {
                allCandidates.addAll(completion.candidates);
            }
        }

        candidates.addAll(allCandidates);

        return max;
    }
4875
private static int countNodes(TreeModel treeModel, Object node)
    {
        int sum = 1;
        int n = treeModel.getChildCount(node);
        for (int i=0; i<n; i++)
        {
            sum += countNodes(treeModel, treeModel.getChild(node, i));
        }
        return sum;
    }
381313
public void addNode(final INodeEntry node) {
        //convert to entity
        final ResourceXMLParser.Entity entity = createEntity(node);
        addEntity(entity);
    }
572969
public static void calculateScores(MultipleAlignment alignment)
			throws StructureException {

		// Put RMSD
		List<Atom[]> trans = MultipleAlignmentTools.transformAtoms(alignment);
		alignment.putScore(RMSD, getRMSD(trans));

		// Put AvgTM-Score
		List<Integer> lengths = new ArrayList<Integer>(alignment.size());
		for (Atom[] atoms : alignment.getAtomArrays()) {
			lengths.add(atoms.length);
		}
		alignment.putScore(AVGTM_SCORE, getAvgTMScore(trans, lengths));
	}
362092
@SuppressWarnings("unchecked")
    public static <T extends Node> void findNodes(List<Node> nodes, Class<T> cls, List<T> results) {
        for (Node n : nodes) {
            if (n instanceof ContainerNode) {
                findNodes(((ContainerNode) n).getNodes(), cls, results);
            }

            if (cls == n.getClass()) {
                results.add((T) n);
            }
        }
    }
646842
public void setNodeTypeSpecificValues(java.util.Collection<NodeTypeSpecificValue> nodeTypeSpecificValues) {
        if (nodeTypeSpecificValues == null) {
            this.nodeTypeSpecificValues = null;
            return;
        }

        this.nodeTypeSpecificValues = new java.util.ArrayList<NodeTypeSpecificValue>(nodeTypeSpecificValues);
    }