Jun 9, 2011 at 5:59 PM
Edited Jun 10, 2011 at 3:39 PM
Also fyi it seems that there is no documentation of the QuickGraph.Graphviz code. Am I missing something?
Here are my thoughts, correct if necessary.
1. GraphvizAlgorithm.Generate() controls how each vertex is written to file.
2. WriteVertices() is called from within the Generate() method.
3. For each vertex in the graph, OnFormatVertex() is called.
4. In OnFormatVertex() a new GraphvizVertex() formatter is created. (A separate formatter - one per method call - is created for each vertex)
5. The FormatVertexEventHandler is called. (Again, happens once per vertex)
6. The ToDot() method is called finally writing each vertex out to file.
To summarize, in order to write each node with a URL, one approach is the following:
1. Create a new class to be used as your "TVertex".
2. This class will contain the URL.
3. Create an event handler method for the FormatVertexEventHandler, in this method, use vertex.formatter.url to set the URL.
My thoughts above were correct, at least the ones pertaining to the delegate and event subscription model that QuickGraph.Graphviz uses in its GraphvizAlgorithm class. I'm still surprised that there is seemingly no documentation of the API, but for anyone
interested, you can use .NET Reflector to look at the code, all you need to do is open the QuickGraph.Graphviz .dll in Reflector. Also see these articles about C# method delegation:
And these links show you how to skip the ".dot" file creation and just create/draw the graph in memory using C#