Skip to content
Snippets Groups Projects
Select Git revision
  • 0cb31d35580969b74b3e82c4d1b5398a87185a84
  • master default protected
2 results

GraphVisualizer.cs

Blame
  • GraphVisualizer.cs 676 B
    using Microsoft.Msagl.Drawing;
    
    namespace FlowForge;
    
    public class GraphVisualizer
    {
        public static Graph ConvertToMsaglGraph(FlowGraph flowGraph)
        {
            Graph msaglGraph = new Graph();
    
            foreach (var vertex in flowGraph.Graph.Vertices)
            {
                var msaglNode = msaglGraph.AddNode(vertex.Id);
                msaglNode.LabelText = vertex.Label; // Use the label from FlowNode
            }
    
            foreach (var edge in flowGraph.Graph.Edges)
            {
                var msaglEdge = msaglGraph.AddEdge(edge.Source.Id, edge.Target.Id);
                msaglEdge.LabelText = $"{edge.CurrentFlow}/{edge.MaxFlow}";
            }
    
            return msaglGraph;
        }
    }