Using Graph# without WPF or Canvas

Jun 27, 2014 at 1:08 PM
Edited Jun 27, 2014 at 1:31 PM

I would like to build a graph from my datas, then calculate the best layout for the graph, and finally get the coordinates of each vertex to draw it in another application (who is not a WPF application, I just want x,y coordinates).

Is it possible using Graph# ?

If yes, which kind of graph do I need ? Which classes/methods do I have to use ?

Thank you very much for your help.
Jun 27, 2014 at 5:24 PM
Edited Jun 27, 2014 at 5:24 PM
Hi, Graph# possibly allows to do what you need to, but ,honestly, i don't remember how and where are all the needed stuff :/
I can advice you to look at GraphX, it has the same algorithms base. You can use smth like:
new AlgorithmFactory<DataVertex, DataEdge, BidirectionalGraph<DataVertex, DataEdge>>().CreateLayoutAlgorithm(LayoutAlgorithmTypeEnum.BoundedFR, graph).VertexPositions
to get vertex positions for specified algorithms. Or you can manualy create and run algorithm. I suppose you will have to use two PCL libs: Common and Logic.
If you'll have any questions feel free to ask on the forums on the main web site.
Jun 27, 2014 at 6:31 PM
Edited Jun 27, 2014 at 6:46 PM
Do you know where I could find help to do what I need ? I spent half of my day looking for example or answers on Google but I found nothing :/

I just downloaded GraphX and tryed your code. I had to make my custom data (which is what you called DataVertex) implements IGraphXVertex, and tryed to do the same thing with edges (I don't have data for it but I built a class) but can't access to IGraphXEdge members (Source, Target)...
So impossible to add edge to my graph.

I also have a version conflict between GraphX.common (version and QuickGraph (version 3.2.40122.0) which prevents me to compile...

That's a bad day haha !
Jun 30, 2014 at 1:29 PM
Edited Jun 30, 2014 at 1:29 PM
I really don't manage to solve the GetVertexControl missing method problem.
In another post, I saw this that this had to work...
var g = new BidirectionalGraph<VertexControl, IEdge<VertexControl>>();
// some code building the graph
var graphLayout = new GraphLayout<VertexControl, IEdge<VertexControl>, BidirectionalGraph<VertexControl, IEdge<VertexControl>>>();
graphLayout.Graph = g;
double x = GraphCanvas.GetX(graphLayout.GetVertexControl(g.Vertices.ElementAt(0))); 
but enable to find why the method doesn't exist.
Jun 30, 2014 at 2:39 PM
Edited Jun 30, 2014 at 2:40 PM
You have conflict because your Quickgraph version is too old. You should update it.
There are plenty examples on how to use GraphX in its source code.

And again, use Graph# source code to biuld DLLs as it contains the most up to date version of the library. The method is in there.
Jul 2, 2014 at 1:05 PM
Perfect i'm able to use the method, I answered on this post , maybe you could help me.
Thank you !