JavaLab2/src/lab2/algorithm/TSP.java
public int TriangleTSP(){
        Node tree = Kruskal();//O(mlog n)
        int cost = 0;
        ArrayList<Integer> path = preorder(tree, new ArrayList<Integer>());//O(n)
        path.add(0);

        for(int i = 0; i < path.size() - 1; i++)
            cost += w.get(path.get(i), path.get(i + 1));

        return cost;
    }
/**
	 * Finds the 2-approximate solution for TSP problem in O(mlog n + n)
	 * @return cost of path of the solution
	*/
Finds the 2-approximate solution for TSP problem in O(mlog n + n)
@return cost of path of the solution
Finds the 2 - approximate solution for TSP problem in O ( mlog n + n ) @return cost of path of the solution
public int TriangleTSP(){
        Node tree = Kruskal();
        int cost = 0;
        ArrayList<Integer> path = preorder(tree, new ArrayList<Integer>());
        path.add(0);
        for(int i = 0; i < path.size() - 1; i++)
            cost += w.get(path.get(i), path.get(i + 1));
        return cost;
    }
public int TriangleTSP ( ) { Node tree = Kruskal ( ) ; int cost = 0 ; ArrayList < Integer > path = preorder ( tree , new ArrayList < Integer > ( ) ) ; path . add ( 0 ) ; for ( int i = 0 ; i < path . size ( ) - 1 ; i ++ ) cost += w . get ( path . get ( i ) , path . get ( i + 1 ) ) ; return cost ; }
Finds the 2-approximate solution for TSP problem in O(mlog n + n)
 @return cost of path of the solution
Finds the 2 - approximate solution for TSP problem in O ( mlog n + n ) @return cost of path of the solution
//O(mlog n) //O(n)