Skip to content

Instantly share code, notes, and snippets.

@tonicanada
Created January 20, 2023 01:53
Show Gist options
  • Save tonicanada/51a61bbe54aca1b81f9b38a41fe139ec to your computer and use it in GitHub Desktop.
Save tonicanada/51a61bbe54aca1b81f9b38a41fe139ec to your computer and use it in GitHub Desktop.
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