Created
January 20, 2023 01:53
-
-
Save tonicanada/51a61bbe54aca1b81f9b38a41fe139ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace TspCadPlugin | |
{ | |
public static class AproxDoubleTree | |
{ | |
public static int[] GetAproxDoubleTree(Double[,] distMatrix) | |
{ | |
int[,] mst = Utils.GetMSTfromDistMatrix(distMatrix); | |
for (int i = 0; i < mst.GetLength(0); i++) | |
{ | |
for (int j = 0; j < mst.GetLength(1); j++) | |
{ | |
if (mst[i, j] > 0) | |
{ | |
mst[i, j] = 2; | |
} | |
} | |
} | |
List<int> path = new List<int>(); | |
path = Hierholzer.HierholderDirectedGraph(0, mst); | |
// Remove duplicates from path | |
path = Utils.RemoveVisitedVerticesFromPath(distMatrix.GetLength(0), path); | |
path.Add(0); | |
return path.ToArray(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment