2

is there anyway to detect all the cycles in an undirected graph generated with quick graph and print the list of cycles. I "googled" a little bit and I came to know that cycles in a graph can be detected using "Depth First Search Algorithm". I then tried something like this:

var g = new UndirectedGraph<int, TaggedUndirectedEdge<int, int>>();

var e1 = new TaggedUndirectedEdge<int, int>(1, 2, 57);//dem(1, 2, 57).
var e2 = new TaggedUndirectedEdge<int, int>(1, 4, 65);//dem(1, 4, 65).
var e3 = new TaggedUndirectedEdge<int, int>(2, 3, 155);//dem(2, 3, 155). 
var e4 = new TaggedUndirectedEdge<int, int>(2, 4, 129);//dem(2, 4, 129).
var e5 = new TaggedUndirectedEdge<int, int>(3, 4, 78);// dem(3, 4, 78).
var e6 = new TaggedUndirectedEdge<int, int>(3, 5, 200);// dem(3, 5, 200).

g.AddVerticesAndEdge(e1);
g.AddVerticesAndEdge(e2);
g.AddVerticesAndEdge(e3);
g.AddVerticesAndEdge(e4);
g.AddVerticesAndEdge(e5);
g.AddVerticesAndEdge(e6);

var dfs = new UndirectedDepthFirstSearchAlgorithm<int, TaggedUndirectedEdge<int, int>>(g);

dfs.Compute();

Now I am looking for a way to print the cycles. (I am not sure if my code is correct this is the first time I deal with quick graph, the first time I even deal with graph in general).

Thank you for your help.

cgadjoro
  • 127
  • 1
  • 7
  • +1 for posting how you instatiated the UndirectedGraph class, since the documentation of C#-QuickGraph seems to lack it. – kiltek May 13 '15 at 13:20
  • So the question is how to PRINT the cycles in the graph? Can you explain your requirement in more detail? (I know this is an old question) – StayOnTarget May 01 '17 at 12:54

0 Answers0