I'm updating a method that exports a graph from .dot to .graphml format.
Previously, colors and labels were set in the FormatEdge and FormatVertex events. I am not clear on where to set the color for graphml.
.Dot Way
...
public ExportDot()
{
IVertexAndEdgeListGraph<TVertex,TEdge> g= ...;
var graphviz = new GraphvizAlgorithm<TVertex,CustomEdge<int>>(g);
graphviz.FormatVertex += OnFormatVertex;
graphviz.FormatEdge += OnFormatEdge;
var output = graphviz.Generate(new FileDotEngine(), "graph");
}
public virtual void OnFormatEdge(object obj,
FormatEdgeEventArgs<TVertex, CustomEdge<int>> e)
{
e.EdgeFormatter.Label.Value = e.Edge.Id.ToString();
e.EdgeFormatter.StrokeColor = Color.Blue;
}
...
Custom Edge class:
public CustomEdge : Edge<TVertex>
{
public int Id {get; set;}
}
.Graphml Way
Some class:
...
public ExportGraphml()
{
var g = new BidirectionalGraph<int, CustomEdge<int>>();
...
using(var xwriter = XmlWriter.Create(...))
g.SerializeToGraphML<int, CustomEdge<int>>(xwriter);
}
Custom Edge class:
public CustomEdge : Edge<TVertex>
{
[XmlAttribute("id")]
public int Id {get; set;}
public virtual string ToLabel()
{
return Id.ToString();
}
}