Search code examples
c#monoquickgraph

QuickGraph, how to use extension method StronglyConnectedComponents


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?


Solution

  • 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.