/// <summary>
/// 有向无回路图中的单源最短路径算法
/// </summary>
public class DAG_Shortest_Paths
{
/// <summary>
/// 有向无回路图中的单源最短路径
/// </summary>
/// <param name="g">有向无回路图</param>
/// <param name="s">源点s</param>
public void DAGShortestPaths(Graphic g, Node s)
{
GraphicSearchAlg theGS = new GraphicSearchAlg();
//获取拓扑排序
var theNodes = theGS.TopoLogicalSort(g);
SingleSourcePath theSSP = new SingleSourcePath();
//初始化图
theSSP.InitializeGraphic(g, s);
foreach (Node theNode in theNodes)
{
foreach (var theAdjNode in theNode.AdjNodes)
{
//利用松弛技术.
theSSP.Relax(theAdjNode.Value);
}
}
}
}
/// 有向无回路图中的单源最短路径算法
/// </summary>
public class DAG_Shortest_Paths
{
/// <summary>
/// 有向无回路图中的单源最短路径
/// </summary>
/// <param name="g">有向无回路图</param>
/// <param name="s">源点s</param>
public void DAGShortestPaths(Graphic g, Node s)
{
GraphicSearchAlg theGS = new GraphicSearchAlg();
//获取拓扑排序
var theNodes = theGS.TopoLogicalSort(g);
SingleSourcePath theSSP = new SingleSourcePath();
//初始化图
theSSP.InitializeGraphic(g, s);
foreach (Node theNode in theNodes)
{
foreach (var theAdjNode in theNode.AdjNodes)
{
//利用松弛技术.
theSSP.Relax(theAdjNode.Value);
}
}
}
}