/
Program.cs
50 lines (37 loc) · 1.33 KB
/
Program.cs
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
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using grafos_sharp.Model;
namespace grafos_sharp
{
class Program
{
static void Main(string[] args)
{
AdjacencyMatrix<char> t = new AdjacencyMatrix<char>((u,v) => u.CompareTo(v), true);
t.AddVertex('s');
t.AddVertex('t');
t.AddVertex('x');
t.AddVertex('y');
t.AddVertex('z');
t.AddEdge('s', 't', 10);
t.AddEdge('s', 'y', 5);
t.AddEdge('t', 'x', 1);
t.AddEdge('t', 'y', 2);
t.AddEdge('x', 'z', 4);
t.AddEdge('y', 't', 3);
t.AddEdge('y', 'z', 2);
t.AddEdge('y', 'x', 9);
t.AddEdge('z', 'x', 6);
AdjacencyList<char> l = (AdjacencyList<char>)t;
Console.WriteLine(t);
Console.WriteLine(l);
Console.WriteLine(TreeAlgorithms<char>.Dijkstra(t, 's'));
Console.WriteLine((AdjacencyList<char>) TreeAlgorithms<char>.Dijkstra(l, 's'));
TreeAlgorithms<char>.BellmanFord(t, 's', out Graph<char> to);
TreeAlgorithms<char>.BellmanFord(t, 's', out Graph<char> lo);
AdjacencyList<char> ttt = (AdjacencyMatrix<char>)lo;
Console.WriteLine(to);
Console.WriteLine(ttt);
}
}
}