gpt4 book ai didi

c# - QuickGraph,如何使用扩展方法 StronglyConnectedComponents

转载 作者:行者123 更新时间:2023-11-30 22:35:35 27 4
gpt4 key购买 nike

作为我第一次使用 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 删除),它编译并运行没有任何问题。

关于c# - QuickGraph,如何使用扩展方法 StronglyConnectedComponents,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7402069/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com