private bool TryPutVerticle(PointF p) { if (PointFColidesWithPolygons(p)) { return(false); } if (Verticles.Count == 0) { Verticles.Add(p); return(true); } foreach (PointF PointF in Verticles) //Chcecking another verticles { if (Math.Abs(PointF.X - p.X) < 8 && Math.Abs(PointF.Y - p.Y) < 8) //Verticle colides with Point { if (PointF == Verticles[0]) { CompletePolygon(); return(true); } else { return(false); } } } Verticles.Add(p); return(true); }
/// <summary> /// Add a new vertex to graph. /// Time complexity: O/1 /// </summary> /// <param name="value"></param> /// <returns></returns> public GraphVertex <T> AddVertex(T value) { if (value == null) { throw new ArgumentNullException(); } var newVertex = new GraphVertex <T>(value); Verticles.Add(value, newVertex); return(newVertex); }
/// <summary> /// Add a new vertex to this graph /// </summary> /// <param name="value"></param> /// <returns></returns> public WeightedDiGraphVertex <T, TW> AddVertex(T value) { if (value == null) { throw new ArgumentException(); } var newVertex = new WeightedDiGraphVertex <T, TW>(value); Verticles.Add(value, newVertex); return(newVertex); }