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(); }
public static NetworkSample Create(GraphPath graphPath, int currentVertex, int label) { NetworkSampleInput input = new NetworkSampleInput(graphPath.Graph, currentVertex); double[] output = new double[graphPath.Graph.Vertices.Length]; output[label] = 1; return(new NetworkSample(graphPath, currentVertex, input.Values, output)); }
public GraphPainter(GraphPath graphPath) { GraphPath = graphPath; Graph graph = graphPath.Graph; Vertices = new PointF[graph.Vertices.Length]; VerticesBrushes = new Brush[graph.Vertices.Length]; Scale = 1; for (int i = 0; i < Vertices.Length; i++) { VerticesBrushes[i] = Brushes.DarkGray; } VerticesBrushes[0] = Brushes.Magenta; VerticesBrushes[Vertices.Length - 1] = Brushes.LightSeaGreen; }
protected NetworkSample(GraphPath graphPath, int currentVertex, double[] input, double[] output) : base(input, output) { GraphPath = graphPath; CurrentVertex = currentVertex; }