-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsert.cs
More file actions
40 lines (34 loc) · 1.05 KB
/
Insert.cs
File metadata and controls
40 lines (34 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Linq;
namespace VisualGraph
{
/// <summary>
/// Inserts the Values from Form1 into the Dijekstra Algorithm
/// </summary>
public class Insert
{
public Dijekstra dijekstra;
public Insert(Dijekstra dij1)
{
dijekstra = dij1;
}
public void insertEdge(String start, String end, double weight)
{
dijekstra.initialVertex.Add(dijekstra.vertexList.IndexOf(NameToVertex(start)));
dijekstra.finalVertex.Add(dijekstra.vertexList.IndexOf(NameToVertex(end)));
dijekstra.weights.Add(weight);
}
public void insertVertex(String name)
{
dijekstra.vertexList.Add(new Vertex(name));
}
Vertex NameToVertex(String name)
{
return dijekstra.vertexList.Where(x => x.name == name).ToList()[0];
}
public String getVertexFromIndex(int index)
{
return dijekstra.vertexList[index].name;
}
}
}