Esempio n. 1
0
        protected void OnSelectedGraphIndexChanged()
        {
            Text = $"{selectedGraphIndex + 1}/{Graphs.Length}";
            GraphPath graphPath = Graphs[selectedGraphIndex];
            Graph     graph     = graphPath.Graph;

            graphPainter        = new GraphPainter(graphPath);
            graphPainter.Scale  = Math.Min(ClientSize.Width, ClientSize.Height);
            dijkstraPathPainter = new GraphPathPainter(graphPainter, graphPath.Path, dijkstraPathPen);

            var input = new NetworkSampleInput(graphPath.Graph, 0);

            bool[] visitStatus = new bool[graph.Vertices.Length];
            visitStatus[0] = true;
            int        currentVertex = 0;
            List <int> path          = new List <int>();

            path.Add(currentVertex);

            do
            {
                visitStatus[currentVertex] = true;
                input.SetCurrentVertex(currentVertex);
                double[] prediction = Network.Evaluate(input.Values);
                currentVertex = prediction.IndexOfMax(0);
                path.Add(currentVertex);
            }while (visitStatus[currentVertex] == false && currentVertex != graph.Vertices.Length - 1);

            networkPathPainter = new GraphPathPainter(graphPainter, path.ToArray(), networkPathPen);
            Refresh();
        }
Esempio n. 2
0
 public GraphPathPainter(GraphPainter graphPainter, int[] path, Pen pen)
 {
     GraphPainter = graphPainter;
     Path         = path;
     Pen          = pen;
 }