Esempio n. 1
0
        private void ShortestPath_Click(object sender, RoutedEventArgs e)
        {
            var graph    = GraphArea1.LogicCore.Graph;
            var vertices = graph.Vertices.ToList();

            if (!vertices.Any())
            {
                return;
            }

            var v1 = vertices.First();
            var v2 = vertices.Last();

            GraphArea1.VertexList[v1].Background = new SolidColorBrush(Colors.OrangeRed);
            GraphArea1.VertexList[v2].Background = new SolidColorBrush(Colors.Blue);

            var path = GraphAlgorithms.FindShortestPathUndirected(graph: graph, startVertex: v1, endVertex: v2);

            HighlightUnOrientedPath(path, Colors.DarkOrange);

            path = GraphAlgorithms.FindShortestPath(graph: graph, startVertex: v1, endVertex: v2);
            HighlightPath(path, Colors.LimeGreen);

            GraphArea1.VertexList[v1].Background = new SolidColorBrush(Colors.OrangeRed);
            GraphArea1.VertexList[v2].Background = new SolidColorBrush(Colors.Blue);
        }