using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes;
namespace WpfApp1 {
public partial class MainWindow : Window { const int size = 10; private Point[] Positions = new Point[size]; private Single[,] Network = new Single[size, size]; private Random R = new Random();
public MainWindow() { InitializeComponent(); }
private void setnet(Single[,] Net, Point[] Pos) { int maxlength = (int)(Math.Min(canvas1.Width, canvas1.Height) * 0.9); int minlength = maxlength / size; for (int i = 0; i < size; i++) { Pos[i].X = R.Next(minlength, maxlength); Pos[i].Y = R.Next(minlength, maxlength); for (int j = 0; j <= i; j++) { Net[i, j] = distance(Pos[i], Pos[j]); Net[j, i] = Net[i, j]; if (i == j) Net[i, j] = 0; } } }
private Single distance(Point a, Point b) { return (Single)Math.Sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y)); }
private void shownet(Single[,] Net) { canvas1.Children.Clear(); Line myLine; for (int i = 0; i < size; i++) { for (int j = 0; j < i; j++) { if (Net[i, j] != 0) { myLine = new Line(); myLine.Stroke = Brushes.Black; myLine.X1 = Positions[i].X; myLine.X2 = Positions[j].X; myLine.Y1 = Positions[i].Y; myLine.Y2 = Positions[j].Y; myLine.StrokeThickness = 1; canvas1.Children.Add(myLine); } } }
void prims() { int[] included = new int[size]; int[] excluded = new int[size]; Single[,] finished = new Single[size, size]; int start = 0; int finish = 0; for (int i = 0; i < size; i++)
Mike James, Founder and Chief Editor of I Programmer is a prolific author. In Deep C#: Dive Into Modern C#, published in September 2021, he provides a “deep dive” into various topics that are important or central to the language. By exploring the motivation behind these key concepts, which is so often ignored in the documentation, the intention is to be thought-provoking and to give developers confidence to exploit C#’s wide range of features.
Finding the minimum spanning tree is one of the fundamental algorithms and it is important in computer science and practical programming. We take a look at the theory and the practice and discover how [ ... ]
Having an accurate weather forecast is critical for many situations, in particular for deciding weather conditions are suitable for to deploy infrastructure inspection drones. This [ ... ]
Bun 1.2 has been released with improvements including progress towards Node.js compatibility, a built-in S3 object storage API and a built-in Postgres client.