public int GetHashCode(Vertix obj) { unchecked // Overflow is fine, just wrap { int hash = 17; // Suitable nullity checks etc, of course :) hash = hash * 23 + obj.Id.GetHashCode(); hash = hash * 23 + obj.Color.GetHashCode(); return(hash); } }
public void Dodaj_wierzchołek(string a) { if (Czy_jest_wierzchołek(a)) { throw new System.ArgumentException("Wierzchołek istnieje"); } Vertix n = new Vertix(a); S.dodaj_element_z_kluczem(a, n); Si.dodaj_element_z_kluczem(liczba_wierz, n); liczba_wierz++; }
public bool Equals(Vertix x, Vertix y) { if (x == null) { return(false); } if (y == null) { return(false); } return(x.Id == y.Id && x.Color == y.Color); }
public void AddEdge(Vertix vertixA, Vertix vertixB) { if (!VertixesWithEdges.ContainsKey(vertixA)) { VertixesWithEdges.Add(vertixA, new List <Vertix>()); } VertixesWithEdges[vertixA].Add(vertixB); if (!directed) { if (!VertixesWithEdges.ContainsKey(vertixB)) { VertixesWithEdges.Add(vertixB, new List <Vertix>()); } VertixesWithEdges[vertixB].Add(vertixA); } }
internal Triangle(Vertix a, Vertix b, Vertix c) { this.A = a; this.B = b; this.C = c; double CA = b.X - a.X; double CB = b.Y - a.Y; double CC = c.X - a.X; double CD = c.Y - a.Y; double CE = CA * (a.X + b.X) + CB * (a.Y + b.Y); double CF = CC * (a.X + c.X) + CD * (a.Y + c.Y); double CG = 2 * (CA * (c.Y - b.Y) - CB * (c.X - b.X)); double dx, dy; // If the points of the triangle are collinear, then just find the // extremes and use the midpoint as the center of the circumcircle. this.X = (CD * CE - CB * CF) / CG; this.Y = (CA * CF - CC * CE) / CG; dx = this.X - a.X; dy = this.Y - a.Y; this.R = dx * dx + dy * dy; }