public DEdge Reverse() { DEdge res = new DEdge(); res.Begin = End; res.End = Begin; return res; }
public void ReadFromConsole() { Console.Write("Enter a number of vertices, please: "); vrt_num = int.Parse(Console.ReadLine()); Console.Write("Enter a number of edges, please: "); edg_num = int.Parse(Console.ReadLine()); G = new List <DEdge> [VerticesCount]; for (int i = 0; i < VerticesCount; ++i) { G[i] = new List <DEdge>(); } string[] sprts = { " " }; for (int i = 0; i < edg_num; ++i) { Console.Write("Enter begin and end of {0} edge, please: ", i + 1); string s; s = Console.ReadLine(); string[] spr_s = s.Split(sprts, StringSplitOptions.RemoveEmptyEntries); DEdge t = new DEdge(int.Parse(spr_s[0]) - 1, int.Parse(spr_s[1]) - 1); G[t.Begin].Add(t); } }
public void ReadFromTxtFile(string file) { StreamReader data; data = new StreamReader(file); string s = data.ReadToEnd(); string[] sprts = { " ", "\r\n" }; string[] spr_s = s.Split(sprts, StringSplitOptions.RemoveEmptyEntries); vrt_num = int.Parse(spr_s[0]); edg_num = int.Parse(spr_s[1]); G = new List <DEdge> [VerticesCount]; for (int i = 0; i < VerticesCount; ++i) { G[i] = new List <DEdge>(); } for (int i = 0; i < edg_num; ++i) { DEdge t = new DEdge(int.Parse(spr_s[i * 2 + 2]) - 1, int.Parse(spr_s[i * 2 + 3]) - 1); G[t.Begin].Add(t); } }
public DEdge Reverse() { DEdge res = new DEdge(); res.Begin = End; res.End = Begin; return(res); }
public DEdge(DEdge edg) { bgn = edg.Begin; end = edg.End; }
public void AddEdge(DEdge edg) { G[edg.Begin].Add(edg); ++edg_num; }
private void PrintVector2D(DEdge edg) { int x1 = VertexCoords[edg.Begin].x; int y1 = VertexCoords[edg.Begin].y; int x2 = VertexCoords[edg.End].x; int y2 = VertexCoords[edg.End].y; double tx = x1 - x2; double ty = y1 - y2; double sq = Math.Sqrt(tx * tx + ty * ty); tx /= sq; ty /= sq; double v1x = 6.5 * tx + ty; double v1y = 6.5 * ty - tx; double v2x = 6.5 * tx - ty; double v2y = 6.5 * ty + tx; sq = Math.Sqrt(v1x * v1x + v1y * v1y); v1x /= sq; v1y /= sq; sq = Math.Sqrt(v2x * v2x + v2y * v2y); v2x /= sq; v2y /= sq; Gl.glBegin(Gl.GL_LINES); Gl.glVertex2d(x1, y1); Gl.glVertex2d(x2, y2); Gl.glVertex2d(x2, y2); Gl.glVertex2d(x2 + 25 * v1x, y2 + 25 * v1y); Gl.glVertex2d(x2, y2); Gl.glVertex2d(x2 + 25 * v2x, y2 + 25 * v2y); Gl.glEnd(); }
public void ReadFromTxtFile(string file) { StreamReader data; data = new StreamReader(file); string s = data.ReadToEnd(); string[] sprts = { " ", "\r\n" }; string[] spr_s = s.Split(sprts, StringSplitOptions.RemoveEmptyEntries); vrt_num = int.Parse(spr_s[0]); edg_num = int.Parse(spr_s[1]); G = new List<DEdge>[VerticesCount]; for (int i = 0; i < VerticesCount; ++i) G[i] = new List<DEdge>(); for (int i = 0; i < edg_num; ++i) { DEdge t = new DEdge(int.Parse(spr_s[i * 2 + 2]) - 1, int.Parse(spr_s[i * 2 + 3]) - 1); G[t.Begin].Add(t); } }
public void ReadFromConsole() { Console.Write("Enter a number of vertices, please: "); vrt_num = int.Parse(Console.ReadLine()); Console.Write("Enter a number of edges, please: "); edg_num = int.Parse(Console.ReadLine()); G = new List<DEdge>[VerticesCount]; for (int i = 0; i < VerticesCount; ++i) G[i] = new List<DEdge>(); string[] sprts = { " " }; for (int i = 0; i < edg_num; ++i) { Console.Write("Enter begin and end of {0} edge, please: ", i + 1); string s; s = Console.ReadLine(); string[] spr_s = s.Split(sprts, StringSplitOptions.RemoveEmptyEntries); DEdge t = new DEdge(int.Parse(spr_s[0]) - 1, int.Parse(spr_s[1]) - 1); G[t.Begin].Add(t); } }