/*
Initializes cut values for all edges in the tree.
425118
function initCutValues(t, g) {
  var vs = postorder(t, t.nodes());
  vs = vs.slice(0, vs.length - 1);
  _.forEach(vs, function(v) {
    assignCutValue(t, g, v);
  });
}
922140
private void initTopicTree(HelpTopicNode htnParent, TreeNode ttnParent) {
        
        for (int i = 0; i < ttnParent.getChildCount(); i++) {
            TreeNode ttnChild = ttnParent.getChildAt(i);
            HelpTopic ht = getTopic(ttnChild);
            HelpTopicNode htnChild = new HelpTopicNode(ht);
            htnParent.addChild(htnChild);
            initTopicTree(htnChild, ttnChild);
        }
        
    }
938170
public void reset() {
		square = null;
		touch = null;
		center.set(-1,-1);
		largestSide = 0;
		smallestSide = Double.MAX_VALUE;
		graph = RESET_GRAPH;
		for (int i = 0; i < edges.length; i++) {
			if ( edges[i] != null )
				throw new RuntimeException("BUG!");
			sideLengths[i] = 0;
		}
	}
1293134
def _init_edges(p2cs, c2ps):
        """"""
        edge_from_to = []
        for parent, children in p2cs.items():
            for child in children:
                # if child in goids_present and parent in goids_present:
                edge_from_to.append((child, parent))
        for parent, children in c2ps.items():
            for child in children:
                # if child in goids_present and parent in goids_present:
                edge_from_to.append((child, parent))
        return edge_from_to
582089
public void init()
    {
        // determine the depth to which we can safely split the tree
        byte sizedepth = (byte)(Math.log10(maxsize) / Math.log10(2));
        byte depth = (byte)Math.min(sizedepth, hashdepth);

        root = initHelper(fullRange.left, fullRange.right, (byte)0, depth);
        size = (long)Math.pow(2, depth);
    }
1289974
private void setSlice() {
        // slicing initialisation
        if (labels == null) {
            double min = base.getPrecisionUnit()[index] * Math.ceil(base.getLowerBounds()[index] / base.getPrecisionUnit()[index]);
            double max = base.getPrecisionUnit()[index] * Math.floor(base.getUpperBounds()[index] / base.getPrecisionUnit()[index]);
            linearSlices = (int) Math.ceil(Math.round((max - min) / base.getPrecisionUnit()[index], 1));
            if (linearSlices <= 0) {
                linearSlices = 1;
            }

            if (linearSlices < 3) {
                linearSlices *= 2;
            }

            linesSlicing = new double[linearSlices + 3];
            labelsSlicing = new double[linearSlices + 3];

            double pitch = (max - min) / linearSlices;
            for (int i = 1; i <= linearSlices + 1; i++) {
                // lines and labels slicing are the same
                linesSlicing[i] = min + (i - 1) * pitch;
                labelsSlicing[i] = min + (i - 1) * pitch;
            }

            linesSlicing[0] = base.getLowerBounds()[index];
            labelsSlicing[0] = base.getLowerBounds()[index];
            linesSlicing[linearSlices + 2] = base.getUpperBounds()[index];
            labelsSlicing[linearSlices + 2] = base.getUpperBounds()[index];

        } else {
            linesSlicing = new double[labels.size() + 2];
            labelsSlicing = new double[labels.size()];
            gridLabelStrings = new String[labels.size()];

            linesSlicing[0] = base.getLowerBounds()[index];

            int i = 1;
            for (String string : labels.keySet()) {
                linesSlicing[i] = labels.get(string);
                labelsSlicing[i - 1] = labels.get(string);
                gridLabelStrings[i - 1] = string;
                i++;
            }

            linesSlicing[i] = base.getUpperBounds()[index];
            Arrays.sort(linesSlicing);
            QuickSort.sort(labelsSlicing, gridLabelStrings);
        }
    }
768998
private function initialize()
    {
        $params = $this->getParameters();
        if ($params !== null) {
            for ($i = 0, $_i = count($params); $i < $_i; $i++) {
                if (self::LINES_KEY == $params[$i]->getName()) {
                    $this->lines = (int) $params[$i]->getValue();
                    continue;
                }
                if (self::SKIP_KEY == $params[$i]->getName()) {
                    $this->skip = (int) $params[$i]->getValue();
                    continue;
                }
            }
        }
    }
1171451
def cut_nodes_edges(graph):
    
    n = len(graph)
    time = 0
    num = [None] * n
    low = [n] * n
    father = [None] * n        # father[v] = None if root else father of v
    critical_childs = [0] * n  # c_c[u] = #childs v s.t. low[v] >= num[u]
    times_seen = [-1] * n
    for start in range(n):
        if times_seen[start] == -1:               # init DFS path
            times_seen[start] = 0
            to_visit = [start]
            while to_visit:
                node = to_visit[-1]
                if times_seen[node] == 0:         # start processing
                    num[node] = time
                    time += 1
                    low[node] = float('inf')
                children = graph[node]
                if times_seen[node] == len(children):  # end processing
                    to_visit.pop()
                    up = father[node]            # propagate low to father
                    if up is not None:
                        low[up] = min(low[up], low[node])
                        if low[node] >= num[up]:
                            critical_childs[up] += 1
                else:
                    child = children[times_seen[node]]   # next arrow
                    times_seen[node] += 1
                    if times_seen[child] == -1:   # not visited yet
                        father[child] = node      # link arrow
                        times_seen[child] = 0
                        to_visit.append(child)    # (below) back arrow
                    elif num[child] < num[node] and father[node] != child:
                        low[node] = min(low[node], num[child])
    cut_edges = []
    cut_nodes = []                                # extract solution
    for node in range(n):
        if father[node] is None:                  # characteristics
            if critical_childs[node] >= 2:
                cut_nodes.append(node)
        else:                                     # internal nodes
            if critical_childs[node] >= 1:
                cut_nodes.append(node)
            if low[node] >= num[node]:
                cut_edges.append((father[node], node))
    return cut_nodes, cut_edges
314138
private void init() {
        width = Double.MAX_VALUE;
        for (int i = 1; i < data.length; i++) {
            double w = Math.abs(data[i][0] - data[i - 1][0]);
            if (width > w) {
                width = w;
            }
        }

        leftTop = new double[data.length][2];
        rightTop = new double[data.length][2];
        leftBottom = new double[data.length][2];
        rightBottom = new double[data.length][2];

        for (int i = 0; i < data.length; i++) {
            leftTop[i][0] = data[i][0] - width / 2;
            leftTop[i][1] = data[i][1];

            rightTop[i][0] = data[i][0] + width / 2;
            rightTop[i][1] = data[i][1];

            leftBottom[i][0] = data[i][0] - width / 2;
            leftBottom[i][1] = 0;

            rightBottom[i][0] = data[i][0] + width / 2;
            rightBottom[i][1] = 0;
        }
    }
303297
private void addFirstSegment(int x, int y) {
		Point2D_I32 p = queuePoints.grow();
		p.set(x,y);
		EdgeSegment s = new EdgeSegment();
		s.points.add(p);
		s.index = 0;
		s.parent = s.parentPixel = -1;
		e.segments.add(s);
		open.add(s);
	}
1181241
private void init()
    {
        TreeNode delegateRoot = null;
        if (delegate != null)
        {
            delegateRoot = (TreeNode) delegate.getRoot();
        }
        thisToDelegate.clear();
        delegateToThis.clear();
        if (delegateRoot == null)
        {
            root = null;
            return;
        }
        root = createNode(delegateRoot);
    }
194347
private function initialize()
    {
        $params = $this->getParameters();
        if ($params !== null) {
            foreach ($params as $param) {
                if (self::LINES_KEY === $param->getName()) {
                    $this->lines = (int) $param->getValue();
                    continue;
                }
                if (self::SKIP_KEY === $param->getName()) {
                    $this->lines = (int) $param->getValue();
                    continue;
                }
            }
        }
    }
129115
@Override
    protected void initializeGraph() {
        super.initializeGraph();

        mDrawMatrix.setValues(mDrawMatrixValues);
        mGraphOverlay.decelerate();

        mSeries     = new ArrayList<ValueLineSeries>();
        mLegendList = new ArrayList<LegendModel>();

        mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mLinePaint.setStrokeWidth(mLineStroke);

        mLegendPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mLegendPaint.setColor(mLegendColor);
        mLegendPaint.setTextSize(mLegendTextSize);
        mLegendPaint.setStrokeWidth(2);
        mLegendPaint.setStyle(Paint.Style.FILL);

        mMaxFontHeight = Utils.calculateMaxTextHeight(mLegendPaint, null);

        mIndicatorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mIndicatorPaint.setColor(mIndicatorLineColor);
        mIndicatorPaint.setTextSize(mIndicatorTextSize);
        mIndicatorPaint.setStrokeWidth(mIndicatorWidth);
        mIndicatorPaint.setStyle(Paint.Style.FILL);

        mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleGestureListener);
        mGestureDetector = new GestureDetector(getContext(), mGestureListener);
        mScroller = new Scroller(getContext());

        mRevealAnimator = ValueAnimator.ofFloat(0, 1);
        mRevealAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                mRevealValue = animation.getAnimatedFraction();

                mDrawMatrix.reset();
                mDrawMatrix.setScale(1, 1.f * mRevealValue, 0, mGraphHeight - mNegativeOffset);

                mGraph.invalidate();
            }
        });
        mRevealAnimator.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mStartedAnimation = false;
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });

        // The scroller doesn't have any built-in animation functions--it just supplies
        // values when we ask it to. So we have to have a way to call it every frame
        // until the fling ends. This code (ab)uses a ValueAnimator object to generate
        // a callback on every animation frame. We don't use the animated value at all.
        mScrollAnimator = ValueAnimator.ofFloat(0, 1);
        mScrollAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                tickScrollAnimation();
                invalidateGlobal();
            }
        });

        if(this.isInEditMode()) {
            ValueLineSeries series1 = new ValueLineSeries();
            series1.setColor(0xFF63CBB0);

            series1.addPoint(new ValueLinePoint(1.4f));
            series1.addPoint(new ValueLinePoint(4.4f));
            series1.addPoint(new ValueLinePoint(2.4f));
            series1.addPoint(new ValueLinePoint(3.2f));
            series1.addPoint(new ValueLinePoint(2.6f));
            series1.addPoint(new ValueLinePoint(5.0f));
            series1.addPoint(new ValueLinePoint(3.5f));
            series1.addPoint(new ValueLinePoint(2.4f));
            series1.addPoint(new ValueLinePoint(0.4f));
            series1.addPoint(new ValueLinePoint(3.4f));
            series1.addPoint(new ValueLinePoint(2.5f));
            series1.addPoint(new ValueLinePoint(1.0f));
            series1.addPoint(new ValueLinePoint(4.2f));
            series1.addPoint(new ValueLinePoint(2.4f));
            series1.addPoint(new ValueLinePoint(3.6f));
            series1.addPoint(new ValueLinePoint(1.0f));
            series1.addPoint(new ValueLinePoint(2.5f));
            series1.addPoint(new ValueLinePoint(1.4f));
            addSeries(series1);
        }
    }
311839
function init_block() {
		var n; // iterates over tree elements

		// Initialize the trees.
		for (n = 0; n < L_CODES;  n++) {
			dyn_ltree[n].fc = 0;
		}
		for (n = 0; n < D_CODES;  n++) {
			dyn_dtree[n].fc = 0;
		}
		for (n = 0; n < BL_CODES; n++) {
			bl_tree[n].fc = 0;
		}

		dyn_ltree[END_BLOCK].fc = 1;
		opt_len = static_len = 0;
		last_lit = last_dist = last_flags = 0;
		flags = 0;
		flag_bit = 1;
	}
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;
    }
  }
1074806
public void init(LblTree t1, LblTree t2) {
		LabelDictionary ld = new LabelDictionary();
		it1 = new InfoTree(t1, ld);
		it2 = new InfoTree(t2, ld);
		size1 = it1.getSize();
		size2 = it2.getSize();
		IJ = new int[Math.max(size1, size2)][Math.max(size1, size2)];
		delta = new double[size1][size2];
		deltaBit = new byte[size1][size2];
		costV = new long[3][size1][size2];
		costW = new long[3][size2];

		// Calculate delta between every leaf in G (empty tree) and all the nodes in F.
		// Calculate it both sides: leafs of F and nodes of G & leafs of G and nodes of
		// F.
		int[] labels1 = it1.getInfoArray(POST2_LABEL);
		int[] labels2 = it2.getInfoArray(POST2_LABEL);
		int[] sizes1 = it1.getInfoArray(POST2_SIZE);
		int[] sizes2 = it2.getInfoArray(POST2_SIZE);
		for (int x = 0; x < sizes1.length; x++) { // for all nodes of initially left tree
			for (int y = 0; y < sizes2.length; y++) { // for all nodes of initially right tree

				// This is an attempt for distances of single-node subtree and anything alse
				// The differences between pairs of labels are stored
				if (labels1[x] == labels2[y]) {
					deltaBit[x][y] = 0;
				} else {
					deltaBit[x][y] =
							1; // if this set, the labels differ, cost of relabeling is set
					// to costMatch
				}

				if (sizes1[x] == 1 && sizes2[y] == 1) { // both nodes are leafs
					delta[x][y] = 0;
				} else {
					if (sizes1[x] == 1) {
						delta[x][y] = sizes2[y] - 1;
					}
					if (sizes2[y] == 1) {
						delta[x][y] = sizes1[x] - 1;
					}
				}
			}
		}
	}
631290
public void setEdges(java.util.Collection<Edge> edges) {
        if (edges == null) {
            this.edges = null;
            return;
        }

        this.edges = new java.util.ArrayList<Edge>(edges);
    }