/*
Method: compute

Computes nodes' positions.
2721
function(property, computeLevels) {
      var prop = property || 'start';
      var node = this.graph.getNode(this.root);
      $.extend(node, {
        'drawn' : true,
        'exist' : true,
        'selected' : true
      });
      NodeDim.compute(this.graph, prop, this.config);
      if (!!computeLevels || !("_depth" in node)) {
        this.graph.computeLevels(this.root, 0, "ignore");
      }
      
      this.computePositions(node, prop);
    }
1330475
private void locateNode(String address, Set<String> nodes, Handler<AsyncResult<String>> doneHandler) {
    locateNode(address, nodes.iterator(), doneHandler);
  }
885335
private static Map<Integer, Integer> computePositions(CodecInfo mtasCodecInfo,
      LeafReader r, LeafReaderContext lrc, String field, List<Integer> docSet)
      throws IOException {
    HashMap<Integer, Integer> positionsData;
    if (mtasCodecInfo != null) {
      // for relatively small numbers, compute only what is needed
      if (docSet.size() < Math.log(r.maxDoc())) {
        positionsData = new HashMap<>();
        for (int docId : docSet) {
          positionsData.put(docId,
              mtasCodecInfo.getNumberOfPositions(field, (docId - lrc.docBase)));
        }
        // compute everything, only use what is needed
      } else {
        positionsData = mtasCodecInfo.getAllNumberOfPositions(field,
            lrc.docBase);
        for (int docId : docSet) {
          if (!positionsData.containsKey(docId)) {
            positionsData.put(docId, 0);
          }
        }
      }
    } else {
      positionsData = new HashMap<>();
      for (int docId : docSet) {
        positionsData.put(docId, 0);
      }
    }
    return positionsData;
  }
1105900
void computeNodeInfo(List<EllipseRotated_F64> ellipses , List<Node> cluster ) {

		// create an info object for each member inside of the cluster
		listInfo.reset();
		for (int i = 0; i < cluster.size(); i++) {
			Node n = cluster.get(i);
			EllipseRotated_F64 t = ellipses.get( n.which );

			NodeInfo info = listInfo.grow();
			info.reset();
			info.ellipse = t;
		}

		addEdgesToInfo(cluster);
		pruneNearlyIdenticalAngles();
		findLargestAnglesForAllNodes();
	}
1006128
public static void computePosition (
        Point center, double xradius, double yradius, double angle, Point pos)
    {
        pos.x = (int)Math.round(center.x + xradius * Math.cos(angle));
        pos.y = (int)Math.round(center.y + yradius * Math.sin(angle));
    }
727496
private void computeFullStartPositionMinimum(int position)
      throws IOException {
    if (ignoreSpans != null && !minFullStartPosition.containsKey(position)) {
      HashSet<Integer> list = baseStartPositionList.get(position);
      HashSet<Integer> newList = new HashSet<>();
      int minimumStartPosition = position;
      while (list != null && !list.isEmpty()) {
        newList.clear();
        for (int startPosition : list) {
          if (minFullStartPosition.containsKey(startPosition)) {
            minimumStartPosition = Math.min(minimumStartPosition,
                minFullStartPosition.get(startPosition));
          } else if (baseStartPositionList.containsKey(startPosition)) {
            newList.addAll(baseStartPositionList.get(startPosition));
          } else {
            if (startPosition < minimumStartPosition) {
              minimumStartPosition = startPosition;
            }
          }
        }
        list.clear();
        list.addAll(newList);
      }
      minFullStartPosition.put(position, minimumStartPosition);
    }
  }
911855
private void dfs() {
    Deque<Node> stack = new LinkedList<>();
    stack.add(tree.getRootNode());
    while (!stack.isEmpty()) {
      Node node = stack.removeLast();
      node.startSize = list.size();
      if (node.getEdges().isEmpty()) {
        // leaf
        list.add(node.depth);
        node.endSize = list.size();
      } else {
        if (!node.equals(tree.getRootNode())) {
          // inner node = not leaf and not root
          innerNodes.add(node);
        }
        for (Edge edge : node.getEdges()) {
          Node endNode = edge.getEndNode();
          endNode.depth = node.depth + edge.getSpan() + 1;
          stack.addLast(endNode);
        }
      }
    }
    // At this point all inner nodes are ordered by the time of entering, so we visit them from last to first
    ListIterator<Node> iterator = innerNodes.listIterator(innerNodes.size());
    while (iterator.hasPrevious()) {
      Node node = iterator.previous();
      int max = -1;
      for (Edge edge : node.getEdges()) {
        max = Math.max(edge.getEndNode().endSize, max);
      }
      node.endSize = max;
    }
  }
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);
  }
1373946
def _compute(self):
        """"""
        x_len = self._len
        y_len = self._order
        self._box.xmax = x_len
        self._box.ymax = y_len

        self._x_pos = [n / 2 for n in range(1, 2 * x_len, 2)]
        self._y_pos = [n / 2 for n in reversed(range(1, 2 * y_len, 2))]

        for j, serie in enumerate(self.series):
            serie.points = [(self._x_pos[i], self._y_pos[j])
                            for i in range(x_len)]
850632
function nodePosition(node) {
  let name = node.nodeName
  let position = 1
  while ((node = node.previousSibling)) {
    if (node.nodeName === name) position += 1
  }
  return position
}
1273584
static int[]
	offsets(final ISeq<? extends FlatTree<? extends Op<?>, ?>> nodes) {
		final int[] offsets = new int[nodes.size()];

		int offset = 1;
		for (int i = 0; i < offsets.length; ++i) {
			final Op<?> op = nodes.get(i).getValue();

			offsets[i] = op.isTerminal() ? -1 : offset;
			offset += op.arity();
		}

		return offsets;
	}
110269
public static <T> Set<Set<Node<T>>> compute(final Graph<T> graph) {
    final Set<Set<Node<T>>> connectedComponents = new LinkedHashSet<>();
    final Set<Node<T>> unmarkedNodes = new LinkedHashSet<>(graph.nodes());

    while (!unmarkedNodes.isEmpty()) {
      Set<Node<T>> connectedComp = new LinkedHashSet<>();
      deepFirstSearch(unmarkedNodes.iterator().next(), connectedComp, unmarkedNodes);
      connectedComponents.add(connectedComp);
    }

    return connectedComponents;
  }
530410
def _compute(self):
        """"""
        self._x_pos = [
            (x + 1) / self._order for x in range(self._order)
        ] if self._order != 1 else [.5]  # Center if only one value

        previous = [[self.zero, self.zero] for i in range(self._len)]
        for i, serie in enumerate(self.series):
            y_height = -sum(serie.safe_values) / 2
            all_x_pos = [0] + self._x_pos
            serie.points = []
            for j, value in enumerate(serie.values):
                poly = []
                poly.append((all_x_pos[i], previous[j][0]))
                poly.append((all_x_pos[i], previous[j][1]))
                previous[j][0] = y_height
                y_height = previous[j][1] = y_height + value
                poly.append((all_x_pos[i + 1], previous[j][1]))
                poly.append((all_x_pos[i + 1], previous[j][0]))
                serie.points.append(poly)

        val_max = max(list(map(sum, cut(self.series, 'values'))) + [self.zero])
        self._box.ymin = -val_max
        self._box.ymax = val_max

        if self.range and self.range[0] is not None:
            self._box.ymin = self.range[0]

        if self.range and self.range[1] is not None:
            self._box.ymax = self.range[1]
537472
private static void compute(int[] in, int[] out, int width, int height, int radius)
    {
        final int widthMinus1 = width - 1;
        final int tableSize = 2 * radius + 1;
        final int[] divide = new int[Constant.UNSIGNED_BYTE * tableSize];

        for (int i = 0; i < Constant.UNSIGNED_BYTE * tableSize; i++)
        {
            divide[i] = i / tableSize;
        }

        int inIndex = 0;
        for (int y = 0; y < height; y++)
        {
            compute(in, out, y, inIndex, divide, width, widthMinus1, height, radius);
            inIndex += width;
        }
    }
928549
def computeNodeValues(cls, graph):
        
        for node in graph['nodes']:
            source_val = np.sum([l['value'] for l in node['sourceLinks']])
            target_val = np.sum([l['value'] for l in node['targetLinks']])
            node['value'] = max([source_val, target_val])
887136
private void computeFullEndPositionList(int position) throws IOException {
    if (ignoreSpans != null && !fullEndPositionList.containsKey(position)) {
      // initial fill
      moveTo(position);
      HashSet<Integer> list = baseEndPositionList.get(position);
      if (list != null && !list.isEmpty()) {
        int maxEndPosition = maxBaseEndPosition.get(position);
        HashSet<Integer> checkList = new HashSet<>();
        HashSet<Integer> subCheckList = new HashSet<>();
        checkList.addAll(list);
        int depth = 1;
        while (!checkList.isEmpty()) {
          if (depth > maximumIgnoreLength) {
            checkList.clear();
            subCheckList.clear();
            throw new IOException("too many successive ignores, maximum is "
                + maximumIgnoreLength);
          } else {
            for (Integer checkItem : checkList) {
              if (fullEndPositionList.get(checkItem) != null) {
                list.addAll(fullEndPositionList.get(checkItem));
                maxEndPosition = Math.max(maxEndPosition,
                    maxFullEndPosition.get(checkItem));
              } else {
                moveTo(checkItem);
                if (baseEndPositionList.containsKey(checkItem)) {
                  list.addAll(baseEndPositionList.get(checkItem));
                  maxEndPosition = Math.max(maxEndPosition,
                      maxBaseEndPosition.get(checkItem));
                  subCheckList.addAll(baseEndPositionList.get(checkItem));
                } else {
                  // ready for checkItem
                }
              }
            }
            checkList.clear();
            checkList.addAll(subCheckList);
            subCheckList.clear();
            depth++;
          }
        }
        fullEndPositionList.put(position, list);
        maxFullEndPosition.put(position, (maxEndPosition - position));
      } else {
        fullEndPositionList.put(position, null);
        maxFullEndPosition.put(position, 0);
      }
    }
  }
192649
synchronized void computeTrees() {
        boolean changed;
        try {
            createBuffers();
            do {
                switchBuffers();
                changed = computeOneLevel();
//System.out.println("Tree obj.   "+heap.idToOffsetMap.treeObj);
//if (changed) System.out.println("Next level  "+nextLevelSize);
            } while (changed);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        deleteBuffers();
//System.out.println("Done!");
    }