public ArrayDeque<int[]> computeEditMapping() {

		// initialize tree and forest distance arrays
		double[][] treedist = new double[size1 + 1][size2 + 1];
		double[][] forestdist = new double[size1 + 1][size2 + 1];
		
		boolean rootNodePair = true;

		// treedist was already computed - the result is in delta and deltaBit
		for (int i = 0; i < size1; i++) {
			treedist[i][0] = i;
		}
		for (int j = 0; j < size2; j++) {
			treedist[0][j] = j;
		}
		for (int i = 1; i <= size1; i++) {
			for (int j = 1; j <= size2; j++) {
				treedist[i][j] = delta[i - 1][j - 1] + deltaBit[i - 1][j - 1];
			}
		}
		
		// forestdist for input trees has to be computed
		forestDist(it1, it2, size1, size2, treedist, forestdist);

		// empty edit mapping
		ArrayDeque<int[]> editMapping = new ArrayDeque<>();

		// empty stack of tree Pairs
		ArrayDeque<int[]> treePairs = new ArrayDeque<>();

		// push the pair of trees (ted1,ted2) to stack
		treePairs.addFirst(new int[] { size1, size2 });

		while (!treePairs.isEmpty()) {

			// get next tree pair to be processed
			int[] treePair = treePairs.removeFirst();
			int lastRow = treePair[0];
			int lastCol = treePair[1];

			// compute forest distance matrix
			if (!rootNodePair) {
				forestDist(it1, it2, lastRow, lastCol, treedist, forestdist);
			}
			rootNodePair = false;

			// compute mapping for current forest distance matrix
			int firstRow = it1.getInfo(POST2_LLD, lastRow - 1) + 1 - 1;
			int firstCol = it2.getInfo(POST2_LLD, lastCol - 1) + 1 - 1;
			int row = lastRow;
			int col = lastCol;
			while ((row > firstRow) || (col > firstCol)) {
				if ((row > firstRow)
						&& (forestdist[row - 1][col] + costDel == forestdist[row][col])) {
					// node with postorderID row is deleted from ted1
					editMapping.addFirst(new int[] { row, 0 });
					row--;
				} else if ((col > firstCol)
						&& (forestdist[row][col - 1] + costIns == forestdist[row][col])) {
					// node with postorderID col is inserted into ted2
					editMapping.addFirst(new int[] { 0, col });
					col--;
				} else {
					// node with postorderID row in ted1 is renamed to node col
					// in ted2

					if ((it1.getInfo(POST2_LLD, row - 1) == it1.getInfo(POST2_LLD, lastRow - 1))
							&& (it2.getInfo(POST2_LLD, col - 1) == it2.getInfo(POST2_LLD, lastCol - 1))) {
						// if both subforests are trees, map nodes
						editMapping.addFirst(new int[] { row, col });
						row--;
						col--;
					} else {
						// pop subtree pair
						treePairs.addFirst(new int[] { row, col });

						// continue with forest to the left of the popped
						// subtree pair
						row = it1.getInfo(POST2_LLD, row - 1) + 1 - 1;
						col = it2.getInfo(POST2_LLD, col - 1) + 1 - 1;
					}
				}
			}
		}
		return editMapping;
	}
public ArrayDeque < int [ ] > computeEditMapping ( ) { double [ ] [ ] treedist = new double [ size1 + 1 ] [ size2 + 1 ] ; double [ ] [ ] forestdist = new double [ size1 + 1 ] [ size2 + 1 ] ; boolean rootNodePair = true ; for ( int i = 0 ; i < size1 ; i ++ ) { treedist [ i ] [ 0 ] = i ; } for ( int j = 0 ; j < size2 ; j ++ ) { treedist [ 0 ] [ j ] = j ; } for ( int i = 1 ; i <= size1 ; i ++ ) { for ( int j = 1 ; j <= size2 ; j ++ ) { treedist [ i ] [ j ] = delta [ i - 1 ] [ j - 1 ] + deltaBit [ i - 1 ] [ j - 1 ] ; } } forestDist ( it1 , it2 , size1 , size2 , treedist , forestdist ) ; ArrayDeque < int [ ] > editMapping = new ArrayDeque < > ( ) ; ArrayDeque < int [ ] > treePairs = new ArrayDeque < > ( ) ; treePairs . addFirst ( new int [ ] { size1 , size2 } ) ; while ( ! treePairs . isEmpty ( ) ) { int [ ] treePair = treePairs . removeFirst ( ) ; int lastRow = treePair [ 0 ] ; int lastCol = treePair [ 1 ] ; if ( ! rootNodePair ) { forestDist ( it1 , it2 , lastRow , lastCol , treedist , forestdist ) ; } rootNodePair = false ; int firstRow = it1 . getInfo ( POST2_LLD , lastRow - 1 ) + 1 - 1 ; int firstCol = it2 . getInfo ( POST2_LLD , lastCol - 1 ) + 1 - 1 ; int row = lastRow ; int col = lastCol ; while ( ( row > firstRow ) || ( col > firstCol ) ) { if ( ( row > firstRow ) && ( forestdist [ row - 1 ] [ col ] + costDel == forestdist [ row ] [ col ] ) ) { editMapping . addFirst ( new int [ ] { row , 0 } ) ; row -- ; } else if ( ( col > firstCol ) && ( forestdist [ row ] [ col - 1 ] + costIns == forestdist [ row ] [ col ] ) ) { editMapping . addFirst ( new int [ ] { 0 , col } ) ; col -- ; } else { if ( ( it1 . getInfo ( POST2_LLD , row - 1 ) == it1 . getInfo ( POST2_LLD , lastRow - 1 ) ) && ( it2 . getInfo ( POST2_LLD , col - 1 ) == it2 . getInfo ( POST2_LLD , lastCol - 1 ) ) ) { editMapping . addFirst ( new int [ ] { row , col } ) ; row -- ; col -- ; } else { treePairs . addFirst ( new int [ ] { row , col } ) ; row = it1 . getInfo ( POST2_LLD , row - 1 ) + 1 - 1 ; col = it2 . getInfo ( POST2_LLD , col - 1 ) + 1 - 1 ; } } } } return editMapping ; }
Compute the minimal edit mapping between two trees. There might be
multiple minimal edit mappings. This function computes only one of them.

The first step of this function is to compute the tree edit distance.
Based on the tree distance matrix the mapping is computed.

@return all pairs (ted1.node,ted2.node) of the minimal edit mapping. Each
element in the collection is an integer array A of size 2, where
A[0]=ted1.node is the postorderID (starting with 1) of the nodes
in ted1 and A[1]=ted2.node is the postorderID in ted2. The
postorderID of the empty node (insertion, deletion) is zero.