public void AddNewGraphEdge(TEdge edge, IDictionary <TVertex, VertexColor> colors = null) { graphForm.SafeInvoke(d => { var v1 = new Node(vertexDescription(edge.Source), edge.Source, vertexComparer); var v2 = new Node(vertexDescription(edge.Target), edge.Target, vertexComparer); if (colors != null) { v1.Color = colors[edge.Source].ToString(); v2.Color = colors[edge.Target].ToString(); } var e1 = new Graphviz4Net.Graphs.Edge <Node>(v1, v2, new Arrow()); if (edgeDescription != null) { e1.Attributes.Add("label", edgeDescription(edge)); } //if (edge.Value != null) // e1.Attributes.Add("label",edge.Value); graphForm.ViewModel.Graph.AddEdgeAndVertices(e1); }); }
public void AddNewTreeEdge(TNode source, TNode target, ITreeAlgorithms <TNode> algorithm = null) { graphForm.SafeInvoke(d => { var n1 = new Node(nodeDescription(source), source, nodeComparer); var n2 = new Node(nodeDescription(target), target, nodeComparer); if (algorithm != null) { n1.Color = algorithm.NodeColors[source].ToString(); n1.Color = algorithm.NodeColors[target].ToString(); } //string edgeString = string.Format("{0}-{1} Connected", v1.ID, v2.ID); var e1 = new Graphviz4Net.Graphs.Edge <Node>(n1, n2, new Arrow()); graphForm.ViewModel.Graph.AddEdgeAndVertices(e1); }); }