Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 |
|
---|
6 | namespace VRPProblemAnalyzer {
|
---|
7 |
|
---|
8 | public static class Utils {
|
---|
9 |
|
---|
10 | public static List<PointD> MatrixToPointList(double[,] vertices) {
|
---|
11 | var points = new List<PointD>();
|
---|
12 | for (int i = 0; i < vertices.GetLength(0); i++) {
|
---|
13 | points.Add(new PointD(vertices[i, 0], vertices[i, 1]));
|
---|
14 | }
|
---|
15 | return points;
|
---|
16 | }
|
---|
17 |
|
---|
18 | public static double GetDistance(double[,] vertices, int source, int target) {
|
---|
19 | return Math.Sqrt(
|
---|
20 | Math.Pow((vertices[source, 0] - vertices[target, 0]), 2) +
|
---|
21 | Math.Pow((vertices[source, 1] - vertices[target, 1]), 2));
|
---|
22 | }
|
---|
23 | }
|
---|
24 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.