日期:2014-05-17 浏览次数:20906 次
// 实验小结 吴新强于2013年3月19日19:20:45 桂电 2507实验室
// 主要学习图结构的实现输出以Dijkstra 算法的最小路径的实现
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Chapter16_1
{
class chapter16
{
static void Main()
{
Graph theGraph = new Graph();
theGraph.AddVertex("A");
theGraph.AddVertex("B");
theGraph.AddVertex("C");
theGraph.AddVertex("D");
theGraph.AddVertex("E");
theGraph.AddVertex("F");
theGraph.AddVertex("G");
theGraph.AddEdge(0, 1, 2);
theGraph.AddEdge(0, 3, 1);
theGraph.AddEdge(1, 3, 3);
theGraph.AddEdge(1, 4, 10);
theGraph.AddEdge(2, 5, 5);
theGraph.AddEdge(2, 0, 4);
theGraph.AddEdge(3, 2, 2);
theGraph.AddEdge(3, 5, 8);
theGraph.AddEdge(3, 4, 2);
theGraph.AddEdge(3, 6, 4);
theGraph.AddEdge(4, 6, 6);
theGraph.AddEdge(6, 5, 1);
Console.WriteLine();
Console.WriteLine("Shortest paths:");
Console.WriteLine();
theGraph.Path();
Console.WriteLine();
}
}
public class DistOriginal
{
public int distance;
public int parentVert;
public DistOriginal(int pv, int d)
{
distance = d;
parentVert = pv;
}
}
public class Vertex
{
public string label;
public bool isInTree;
&nbs