作为我第一次使用C#(在Mono 2.6.7上)进行的实验的一部分,我试图使用QuickGraph中的StronglyConnectedComponents方法。这是我的代码:

using System;
using QuickGraph;
using QuickGraph.Data;
using System.Collections.Generic;
using QuickGraph.Algorithms;

namespace Graph
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            IVertexListGraph<int,Edge<int>> graph;
            graph = new AdjacencyGraph<int,Edge<int>>();
            IDictionary<int,int> components=new Dictionary<int,int>();
            int noc = graph.StronglyConnectedComponents(out components);
        }
    }
}


当尝试编译上面的代码时,我收到错误消息(在MonoDevelop中):

Error CS1061: Type `QuickGraph.IVertexListGraph<int,QuickGraph.Edge<int>>' does not
contain a definition for `StronglyConnectedComponents' and no extension method
`StronglyConnectedComponents' of type
`QuickGraph.IVertexListGraph<int,QuickGraph.Edge<int>>' could be found
(are you missing a using directive or an assembly reference?) (CS1061) (Graph)


从文档中可以看到,扩展方法应该可用:

public static int StronglyConnectedComponents<TVertex, TEdge>(
    IVertexListGraph<TVertex, TEdge> g,
    out IDictionary<TVertex, int> components
)


另外,我从QuickGraph引用了所有三个.dll。我想念什么?

最佳答案

好的,我刚刚检查了一下,它在我目前拥有的Mono 2.10.5(Ubuntu)上适用于我,因此请考虑进行更新。 2.6.7很老了。我刚刚下载了快速图形库,仅引用了一个dll(QuickGraph.dll),复制了您的代码(使用QuickGraph.Data删除了该代码),它可以编译并运行而没有任何问题。

07-27 14:04