小编Azu*_*cho的帖子

Dijkstra的算法问题

我正在开展一个项目,我必须找到12个城市之间的最短路径,从西雅图开始,到迈阿密结束.我正在使用Dijkstra的算法,因为路径是加权的.到目前为止,这是我的代码,除了我得到的答案不是我需要的答案之外,它都有效,尽管它是正确的.

这部分代码设置了所有内容以及创建排序算法.

class Graph
{
    Dictionary<string, Dictionary<string, int>> vertices = new Dictionary<string, Dictionary<string, int>>();

    public void add_vertex(string name, Dictionary<string, int> edges)
    {
        vertices[name] = edges;
    }

    public List<string> shortest_path(string start, string finish)
    {
        var previous = new Dictionary<string, string>();
        var distances = new Dictionary<string, int>();
        var nodes = new List<string>();

        List<string> path = null;

        foreach (var vertex in vertices)
        {
            if (vertex.Key == start)
            {
                distances[vertex.Key] = 1;
            }
            else
            {
                distances[vertex.Key] = int.MaxValue;
            }

            nodes.Add(vertex.Key);
        }

        while (nodes.Count != …
Run Code Online (Sandbox Code Playgroud)

c# dijkstra console-application

5
推荐指数
1
解决办法
1017
查看次数

在消息框中插入图像

我想知道如何在我设置的消息框中显示图像,这样每当鼠标输入标签时,它就会显示消息框.代码插入图像的代码是什么?

.net c# asp.net image messagebox

3
推荐指数
1
解决办法
3万
查看次数

标签 统计

c# ×2

.net ×1

asp.net ×1

console-application ×1

dijkstra ×1

image ×1

messagebox ×1