Hi RichardRivaldo-2611,
I made a test via Microsoft.Msagl.GraphViewerGdi you can refer to.
private void Form1_Load(object sender, EventArgs e)
{
//create a viewer object
Microsoft.Msagl.GraphViewerGdi.GViewer viewer= new Microsoft.Msagl.GraphViewerGdi.GViewer();
//create a graph object
Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
//set graph back color
//graph.Attr.BackgroundColor = Microsoft.Msagl.Drawing.Color.Gray;
//create the graph content
graph.AddEdge("A", "B");
graph.AddEdge("B", "C");
graph.FindNode("A").Attr.FillColor =Microsoft.Msagl.Drawing.Color.Red;
graph.FindNode("B").Attr.FillColor =Microsoft.Msagl.Drawing.Color.Green;
Microsoft.Msagl.Drawing.Node c =graph.FindNode("C");
c.Attr.FillColor =Microsoft.Msagl.Drawing.Color.PaleGreen;
c.Attr.Shape =Microsoft.Msagl.Drawing.Shape.Diamond;
//bind the graph to the viewer
viewer.Graph = graph;
//associate the viewer with the form
this.SuspendLayout();
viewer.Dock =System.Windows.Forms.DockStyle.Fill;
this.Controls.Add(viewer);
this.ResumeLayout();
}
The result:
More details you can refe to this document.
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.