Esempio n. 1
0
        private static void TestLabelCorrecting()
        {
            //Graph for figure 5.10 part A
            Graph g = new Graph();

            g.Directed = true;
            Vertex v1 = new Vertex();
            Vertex v2 = new Vertex();
            Vertex v3 = new Vertex();
            Vertex v4 = new Vertex();
            Vertex v5 = new Vertex();
            Vertex v6 = new Vertex();

            g.AddEdge(new Edge(v1, v2, 10));
            g.AddEdge(new Edge(v1, v3, 15));
            g.AddEdge(new Edge(v2, v3, 25));
            g.AddEdge(new Edge(v3, v2, -20));
            g.AddEdge(new Edge(v2, v4, 0));
            g.AddEdge(new Edge(v2, v5, 5));
            g.AddEdge(new Edge(v4, v5, -5));
            g.AddEdge(new Edge(v5, v4, 10));
            g.AddEdge(new Edge(v5, v3, 30));

            Console.WriteLine("Label Correcting Output:");
            Graph labelCorrect = GraphAlgorithms.LabelCorrecting(g, 0);
        }
Esempio n. 2
0
        private void onLabelCorrecting(object sender, EventArgs e)
        {
            if (CurrentGraphPanel == null)
            {
                return;
            }

            //Make sure one vertex is selected
            List <ISelectable> selection = CurrentGraphPanel.GetSelection();
            GUIVertex          vert;

            if (selection.Count <= 0 || selection.Count > 1)
            {
                return;
            }
            else if (selection[0] as GUIVertex == null)
            {
                return;
            }
            else
            {
                vert = selection[0] as GUIVertex;
            }

            List <GUIVertex> verts = CurrentGraphPanel.Vertices;
            Graph            g     = CurrentGraphPanel.Graph;

            GraphAlgorithms.LabelCorrecting(g, g.GetVertices().IndexOf(vert.Vertex));
        }