예제 #1
0
 // ----Конструкторы
 public FormMaxBipartiteMatchingProblem()
 {
     InitializeComponent();
     graphVisInterface = graphVisualizer;
     graphVisInterface.EdgeSelectedEvent   += EdgeSelectedHandler;
     graphVisInterface.VertexSelectedEvent += VertexSelectedHandler;
 }
예제 #2
0
        /// <summary>
        /// Builds the node visualisation.
        /// </summary>
        /// <param name="point">The point.</param>
        /// <param name="graphVisualizer">The graph visualizer.</param>
        private static void buildNodeVisualisation(ProgramPointBase point, IGraphVisualizer graphVisualizer)
        {
            string id    = "pp" + point.ProgramPointID.ToString();
            string label = string.Format("{0}\n{1}",
                                         point.GetType().Name.ToString(), point.ToString());

            graphVisualizer.AddNode(id, label);
        }
예제 #3
0
        /// <summary>
        /// Builds the graph visualisation using given visualiser.
        ///
        /// User of this method can specify types of program points which should be skipped - these nodes
        /// won't appear in final graph and all edges to this nodes will be connected with the nearest
        /// permitted parent.
        /// </summary>
        /// <param name="graphVisualizer">The graph visualizer.</param>
        /// <param name="skipProgramPoints">Types of programpoints which should be skipped from the visualisation.</param>
        public void BuildGraphVisualisation(IGraphVisualizer graphVisualizer, Type[] skipProgramPoints)
        {
            HashSet <ProgramPointGraph> processedGraphs = new HashSet <ProgramPointGraph>();

            processedGraphs.Add(this);

            BuildGraphVisualisation(graphVisualizer, skipProgramPoints, processedGraphs);
        }
예제 #4
0
        /// <summary>
        /// Builds the graph visualisation.
        /// </summary>
        /// <param name="graphVisualizer">The graph visualizer.</param>
        /// <param name="skipProgramPoints">The skip program points.</param>
        /// <param name="processedGraphs">The processed graphs.</param>
        private void BuildGraphVisualisation(IGraphVisualizer graphVisualizer, Type[] skipProgramPoints, HashSet <ProgramPointGraph> processedGraphs)
        {
            foreach (var point in Points)
            {
                bool skip = isTypeOf(point.GetType(), skipProgramPoints);

                if (!skip)
                {
                    buildNodeVisualisation(point, graphVisualizer);
                    buildEdgesVisualisation(point, graphVisualizer, skipProgramPoints);
                    enqueBuildingExtensionVisualisations(point, graphVisualizer, skipProgramPoints, processedGraphs);
                }
            }
        }
예제 #5
0
 // --Изменение визуализатора
 private void SetVisualizer()
 {
     SuspendLayout();
     // Удаляем старый элемент управления
     if (visualizer != null)
     {
         groupBoxViz.Controls.Clear();
         visualizer.VertexSelectedEvent -= OnSelectedVertex;
         visualizer.EdgeSelectedEvent   -= OnSelectedEdge;
     }
     // Добавляем новый
     if (radioButtonVisualizatorSgvl.Checked)
     {
         SimpleGraphVisualizer sgv = new SimpleGraphVisualizer();
         sgv.Dock = DockStyle.Fill;
         groupBoxViz.Controls.Add(sgv);
         visualizer = sgv;
     }
     else
     {
         MsaglGraphVisualizer msaglv = new MsaglGraphVisualizer();
         msaglv.Dock = DockStyle.Fill;
         groupBoxViz.Controls.Add(msaglv);
         visualizer = msaglv;
     }
     ResumeLayout();
     // Инициализируем его графом
     if (visualizingGraph != null)
     {
         visualizer.Initialize(visualizingGraph);
     }
     groupBoxViz.Invalidate();
     // Задаём настройки
     SetVisualizerInteractiveMode();
     // Подписываемся на события
     visualizer.VertexSelectedEvent += OnSelectedVertex;
     visualizer.EdgeSelectedEvent   += OnSelectedEdge;
 }
예제 #6
0
        /// <summary>
        /// Builds the edges visualisation.
        /// </summary>
        /// <param name="point">The point.</param>
        /// <param name="graphVisualizer">The graph visualizer.</param>
        /// <param name="skipProgramPoints">The skip program points.</param>
        private static void buildEdgesVisualisation(ProgramPointBase point, IGraphVisualizer graphVisualizer, Type[] skipProgramPoints)
        {
            HashSet <int> processed = new HashSet <int>();
            LinkedList <ProgramPointBase> edgeQueue = new LinkedList <ProgramPointBase>();

            foreach (var targetPoint in point.FlowChildren)
            {
                edgeQueue.AddLast(targetPoint);
                processed.Add(targetPoint.ProgramPointID);
            }

            string id = "pp" + point.ProgramPointID.ToString();

            while (edgeQueue.Count > 0)
            {
                ProgramPointBase targetPoint = edgeQueue.First.Value;
                edgeQueue.RemoveFirst();

                bool targetSkipped = isTypeOf(targetPoint.GetType(), skipProgramPoints);
                if (!targetSkipped)
                {
                    string outId = "pp" + targetPoint.ProgramPointID;
                    graphVisualizer.AddEdge(id, outId, "");
                }
                else
                {
                    foreach (var p in targetPoint.FlowChildren)
                    {
                        if (!processed.Contains(p.ProgramPointID))
                        {
                            edgeQueue.AddLast(p);
                            processed.Add(p.ProgramPointID);
                        }
                    }
                }
            }
        }
예제 #7
0
 // ----Методы для настройки визуализатора
 private void SetVisualizer(bool isSimple)
 {
     groupBoxVisualization.SuspendLayout();
     groupBoxVisualization.Controls.Clear();
     if (isSimple)
     {
         msaglGraphVisualizer  = null;
         simpleGraphVisualizer = new SimpleGraphVisualizer();
         groupBoxVisualization.Controls.Add(simpleGraphVisualizer);
         simpleGraphVisualizer.Dock = DockStyle.Fill;
         graphVisInterface          = simpleGraphVisualizer;
     }
     else
     {
         simpleGraphVisualizer = null;
         msaglGraphVisualizer  = new MsaglGraphVisualizer();
         groupBoxVisualization.Controls.Add(msaglGraphVisualizer);
         msaglGraphVisualizer.Dock = DockStyle.Fill;
         graphVisInterface         = msaglGraphVisualizer;
     }
     groupBoxVisualization.ResumeLayout();
     graphVisInterface.EdgeSelectedEvent   += EdgeSelectedHandler;
     graphVisInterface.VertexSelectedEvent += VertexSelectedHandler;
 }
예제 #8
0
        /// <summary>
        /// Enques the building extension visualisations recursively.
        /// </summary>
        /// <param name="point">The point.</param>
        /// <param name="graphVisualizer">The graph visualizer.</param>
        /// <param name="skipProgramPoints">The skip program points.</param>
        /// <param name="processedGraphs">The processed graphs.</param>
        private static void enqueBuildingExtensionVisualisations(ProgramPointBase point, IGraphVisualizer graphVisualizer, Type[] skipProgramPoints, HashSet <ProgramPointGraph> processedGraphs)
        {
            bool hasBranches = false;

            foreach (var extension in point.Extension.Branches)
            {
                var ppg = extension.Graph;
                if (!processedGraphs.Contains(ppg))
                {
                    processedGraphs.Add(ppg);
                    extension.Graph.BuildGraphVisualisation(graphVisualizer, skipProgramPoints, processedGraphs);
                }
                buildNodeVisualisation(extension, graphVisualizer);
                buildEdgesVisualisation(extension, graphVisualizer, skipProgramPoints);

                hasBranches = true;
            }

            if (hasBranches)
            {
                buildNodeVisualisation(point.Extension.Sink, graphVisualizer);
                buildEdgesVisualisation(point.Extension.Sink, graphVisualizer, skipProgramPoints);
            }
        }