public GravityForce(Graph my_g,double area) { Graph g = new Graph(my_g); l = Math.Sqrt(area / g.n); delta = new double[g.n]; delta = delta.Select(ll=>0.2).ToArray(); }
public override Bitmap DrawGraph(Graph graph) { Vertex[] v = graph.vertexs; Find(v); int n = v.Length; bool[] used = new bool[n]; kx =(xmax - xmin)/ (Xmax-Xmin); ky = (ymax - ymin)/(Ymax - Ymin); if (kx > ky) { ky = ky /kx; kx = 1; } else { kx = kx /ky; ky = 1; } for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { if (graph.edges[i, j] == 1) subject.g.DrawLine(subject.myPen, toPoint(v[i].x, v[i].y), toPoint(v[j].x, v[j].y)); } foreach (Vertex p in v) { Point centre = toPoint(p.x, p.y); subject.ellipseBounds = new Rectangle(new Point(centre.X-size/2,centre.Y-size/2), new Size(size, size)); subject.g.FillEllipse(subject.redBrush, subject.ellipseBounds); } SetConst(); return subject.picture; }
public Fruchterman_Reingold(Graph my_g, double my_w, double my_h) { l = Math.Sqrt(my_h * my_w / my_g.n); delta = my_w; w = my_w; h = my_h; g = new Graph(my_g); optimumPosition = false; }
public Fruchterman_Reingold(int my_m, Graph my_g,double my_w,double my_h) { m = my_m; w = my_w; h = my_h; l = Math.Sqrt(h*w/my_g.n); delta = w; ; g = new Graph(my_g); optimumPosition = false; }
public SpringEmbered(Graph g1) { m = 200; c1 = 1.0; c2 = 1.0; l = 1.0; k = 0.1; g = new Graph(g1); optimumPosition = false; changePosition(); }
public SpringEmbered(int my_m, double my_c1, double my_c2, double my_l, double my_k, Graph my_g) { m = my_m; c1 = my_c1; c2 = my_c2; l = my_l; k = my_k; g = new Graph(my_g); optimumPosition = false; changePosition(); }
public Graph(Graph g1) { n = g1.n; Array.Copy(g1.l, l, 2); vertexs = new Vertex[n]; edges = new int[n, n]; degs = new int[n]; Array.Copy(g1.edges, edges, n * n); Array.Copy(g1.degs, degs, n); vertexs = g1.vertexs.Select(b => b.Clone()).ToArray(); }
public Graph ReadInput() { String s; Graph new_graph; var sep = new Char[] { ' ' }; int[,] matrix; System.IO.StreamReader file = new System.IO.StreamReader(@"C:\Users\pavel\documents\visual studio 2013\Projects\visualizacia\input.txt"); s = s = file.ReadLine(); var split = s.Split(sep); int n = Int16.Parse(split[0]); matrix = new int[n, n]; int[] degs = new int[n]; Vertex[] V = new Vertex[n]; V[0] = new Vertex(5.0, 5.0); V[1] = new Vertex(5.0, 30.0); V[2] = new Vertex(100.0, 5.0); int deg = 0; double distance = 1; double l = 1; int[] length = new int[2]; for(int i = 0; i<n; i++){ s = file.ReadLine(); split = s.Split(sep); int m = split.Length; deg = 0; for (int j = 0; j < m;j++ ) { matrix[i, j] = Int16.Parse(split[j]); if (matrix[i, j] == 1) { //distance = Math.Sqrt((V[i].x - V[j].x) * (V[i].x - V[j].x) + (V[i].y - V[j].y) * (V[i].y - V[j].y)); if (distance > l) { //l = distance; //length[0] = i; // length[1] = j; } deg++; } } degs[i] = deg; } new_graph = new Graph(n,matrix,degs); new_graph.SetSizeEdge(length); file.Close(); return new_graph; }
private void button2_Click(object sender, EventArgs e) { //sdfmdskfmdslfmdskmfsdkfs graphForDraw = ReadInput(); button2.Visible = false; int Xmax, Ymax; pictureBox1.Dock = DockStyle.Left; //Xmax = ClientSize.Width; //Ymax = ClientSize.Height; Size size = pictureBox1.Size; Xmax = size.Width; Ymax = size.Height; //pictureBox1.Size = new Size(Xmax,Ymax); //graphForDraw.GenerateVertexsPosition(Xmax - 10, Ymax - 10); var viz = new Vizualization(Xmax, Ymax); areaDraw = new DrawWithSize(viz,30); areaDraw.Background(); //areaDraw.DrawGraph(graphForDraw); Point p1 = new Point(0,0); Point p2 = new Point(Xmax,Ymax); areaDraw.DrawLine(p1, p2); pictureBox1.Image = areaDraw.getPicture(); pictureBox1.Update(); button1.Visible = true; }
public virtual Bitmap DrawGraph(Graph graph) { Vertex[] v = graph.vertexs; Find(v); double l = graph.getSizeEdge()/10; int n = v.Length; xmin = xmin - l / 2; xmax = xmax + l / 2; ymin = ymin - l / 2; ymax = ymax + l / 2; bool[] used = new bool[n]; Point p1 = toPoint(v[0].x, v[0].y); Point p2 = toPoint(v[0].x + l, v[0].y - l); int dx = Math.Abs(p1.X - p2.X); int dy = Math.Abs(p1.Y - p2.Y); size = Math.Min(dx, dy); kx = size * 1.0 / dx; ky = size * 1.0 / dy; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { if (graph.edges[i, j] == 1) subject.g.DrawLine(subject.myPen, toPoint(v[i].x, v[i].y), toPoint(v[j].x, v[j].y)); } foreach (Vertex p in v) { Point centre = toPoint(p.x - l / 2, p.y + l / 2); subject.ellipseBounds = new Rectangle(centre, new Size(size, size)); subject.g.FillEllipse(subject.redBrush, subject.ellipseBounds); } SetConst(); return subject.picture; }