Пример #1
0
		public override bool Equals(object obj)
		{
			if (this == obj) return true;
			if (obj == null) return false;
			if (GetType() != obj.GetType()) return false;

			Edge<T> other = obj as Edge<T>;
			if (Vertex1 == null)
			{
				if (other?.Vertex1 != null)
					return false;
			}
			else if (!Vertex1.Equals(other?.Vertex1))
				return false;

			if (Vertex2 == null)
			{
				if (other?.Vertex2 != null)
					return false;
			}
			else if (!Vertex2.Equals(other?.Vertex2))
				return false;

			return true;
		}
Пример #2
0
        private bool Equals(MyTriangle p)
        {
            bool flag = false;

            if (Vertex1.Equals(p.Vertex1))
            {
                if (Vertex2.Equals(p.Vertex2))
                {
                    if (Vertex3.Equals(p.Vertex3))
                    {
                        flag = true;
                    }
                }
                if (Vertex2.Equals(p.Vertex3))
                {
                    if (Vertex3.Equals(p.Vertex2))
                    {
                        flag = true;
                    }
                }
            }
            if (Vertex1.Equals(p.Vertex2))
            {
                if (Vertex2.Equals(p.Vertex1))
                {
                    if (Vertex3.Equals(p.Vertex3))
                    {
                        flag = true;
                    }
                }
                if (Vertex2.Equals(p.Vertex3))
                {
                    if (Vertex3.Equals(p.Vertex1))
                    {
                        flag = true;
                    }
                }
            }
            if (Vertex1.Equals(p.Vertex3))
            {
                if (Vertex2.Equals(p.Vertex1))
                {
                    if (Vertex3.Equals(p.Vertex2))
                    {
                        flag = true;
                    }
                }
                if (Vertex2.Equals(p.Vertex2))
                {
                    if (Vertex3.Equals(p.Vertex1))
                    {
                        flag = true;
                    }
                }
            }
            return(flag);
        }
Пример #3
0
 /// <inheritdoc />
 public bool Equals(Triangle other)
 {
     if (ReferenceEquals(other, null))
     {
         return(false);
     }
     if (ReferenceEquals(other, this))
     {
         return(true);
     }
     return((Vertex1?.Equals(other.Vertex1) ?? false) &&
            (Vertex2?.Equals(other.Vertex2) ?? false) &&
            (Vertex3?.Equals(other.Vertex3) ?? false));
 }
Пример #4
0
        public Vertex getOtherVertex(Vertex currentVertex)
        {
            Vertex nextVertex = null;

            if (Vertex1.Equals(currentVertex))
            {
                nextVertex = Vertex2;
            }
            else if (Vertex2.Equals(currentVertex))
            {
                nextVertex = Vertex1;
            }

            return(nextVertex);
        }
Пример #5
0
        /// <summary>
        /// Indicates whether the current <see cref="UndirectedWeightedEdge{TVertex}"/>
        /// is equal to another <see cref="UndirectedWeightedEdge{TVertex}"/>.
        /// </summary>
        /// <param name="other">
        /// The <see cref="UndirectedWeightedEdge{TVertex}"/> to compare with this
        /// object.
        /// </param>
        /// <returns>
        /// <see langword="true"/> if the other
        /// <see cref="UndirectedWeightedEdge{TVertex}"/> is equal to this
        /// <see cref="UndirectedWeightedEdge{TVertex}"/>; otherwise,
        /// <see langword="false"/>.
        /// </returns>
        /// <seealso cref="IEquatable{T}.Equals(T)"/>
        public bool Equals(UndirectedWeightedEdge <TVertex> other)
        {
            if (other == null)
            {
                return(false);
            }

            bool sameVerticesSameOrder =
                Vertex1.Equals(other.Vertex1) && Vertex2.Equals(other.Vertex2);

            bool sameVerticesDifferentOrder =
                Vertex1.Equals(other.Vertex2) && Vertex2.Equals(other.Vertex1);

            return((sameVerticesSameOrder || sameVerticesDifferentOrder) &&
                   Weight.Equals(other.Weight));
        }
Пример #6
0
 public bool Contains(Vertex vertex)
 {
     return(Vertex1.Equals(vertex) || Vertex2.Equals(vertex));
 }
Пример #7
0
 private void dfs(Vertex2 v, Vertex2 prev, List<Vertex2> visited)
 {
     HashSet<Vertex2> c = connectionMap[v];
     foreach (Vertex2 w in connectionMap[v]) {
         if(!visited.Contains(w) && (prev == null || !prev.Equals (w))) {
             visited.Add (w);
             dfs (w, v, visited);
         }
     }
 }