开发者

QuickGraph, how to use extension method StronglyConnectedComponents

开发者 https://www.devze.com 2023-04-05 01:34 出处:网络
As part of my first experiments with C# (on Mono 2.6.7) , I am trying to use the StronglyConnectedComponents method from QuickGraph. Here is my code:

As part of my first experiments with C# (on Mono 2.6.7) , I am trying to use the StronglyConnectedComponents method from QuickGraph. Here is my code:

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);
        }
    }
}

When trying to compile the code above, I get the error message (in 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)

As开发者_开发百科 for as I can see from the documentation, the extension method should be available:

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

Also, I referred all three .dll's from QuickGraph. What am I missing?


Ok, I just checked it out and it works for me on Mono 2.10.5 (Ubuntu), which I currently have, so consider updating. 2.6.7 is very old. I just downloaded quick graph library, referenced only one dll (QuickGraph.dll), copypasted your code (just removed using QuickGraph.Data) and it compiles and runs without any problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消