Esempio n. 1
0
        static void Main(string[] args)
        {
            string[]      graphFileLines = System.IO.File.ReadAllLines(@"C:\Users\Josip\Documents\FAKS\NASP\LAB3\graph3.txt");
            WeightedGraph graph          = new WeightedGraph(graphFileLines);

            ShortestPathCalculator.CalcShortestPath(graph);
        }
Esempio n. 2
0
        private void showPath()
        {
            pathCalculator.CalcShortestPath(graph, startVertex, endVertex);
            Boolean noPath = false;
            int     wSum   = 0;

            lbPath.Items.Clear();
            for (int i = 0; i < pathCalculator.Path.Count; i++)
            {
                string vertex = pathCalculator.Path[i];
                if (vertex == null)
                {
                    noPath = true;
                    break;
                }
                lbPath.Items.Add(vertex);
                int w = pathCalculator.PathWeights[i];
                lbPath.Items.Add("+" + w);
                wSum += w;
            }
            if (noPath)
            {
                lbPath.Items.Add("Do ovog mjesta ne postoji put!");
                lblWSum.Visible = true;
                tbWSum.Visible  = true;
                tbWSum.Text     = "? km";
            }
            else
            {
                lbPath.Items.Add(endVertex);
                lblWSum.Visible = true;
                tbWSum.Visible  = true;
                tbWSum.Text     = wSum + " km";
            }
        }