Can anyone point me to an example of how to use Graph# via ElementHost in a winforms application (c#).
Especially loading *.gml - files and showing the Graph-control.
Any help appreciated.
Graph sampling is a technique to pick a subset of vertices and/ or edges from original graph. It has a wide spectrum of applications, e.g. survey hidden population in sociology [54], visualize social graph [29], scale down Internet AS graph [27], graph sparsification [8], etc.
Three types of graphs are used in this course: line graphs, pie graphs, and bar graphs.
The basic idea is to create a WPF user control, that encapsulates a Graph # canvas. This user control is what you would then display in the ElementHost.
I have put together a small sample application that demonstrates this by basically exposing the GraphSharp.Sample.TestCompoundLayout window as user control.
http://cl.ly/0w350230200g0w0o2R2N
I also added loading from GML files which basically boils down to this function:
var graph = new CompoundGraph<object, IEdge<object>>();
try
{
//open the file of the graph
var reader = XmlReader.Create(fileName);
//create the serializer
var serializer = new GraphMLDeserializer<object, IEdge<object>, CompoundGraph<object, IEdge<object>>>();
//deserialize the graph
serializer.Deserialize(reader, graph,
id => id, (source, target, id) => new Edge<object>(source, target)
);
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
layout.Graph = graph;
layout.UpdateLayout();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With