Exemplo n.º 1
0
    //public override bool Equals(object obj)
    //{
    //    return obj is Edge edge &&
    //           (NodeFrom.Equals(edge.NodeFrom) &&
    //           NodeTo.Equals(edge.NodeTo) ||
    //           NodeFrom.Equals(edge.NodeTo) &&
    //           NodeTo.Equals(edge.NodeFrom)) &&
    //           Weight == edge.Weight;
    //}

    public override bool Equals(object obj)
    {
        return(obj is Edge edge &&
               NodeFrom.Equals(edge.NodeFrom) &&
               NodeTo.Equals(edge.NodeTo) &&
               Weight == edge.Weight);
    }
Exemplo n.º 2
0
    //public bool Equals(Edge other)
    //{
    //    return
    //   (NodeFrom.Equals(other.NodeFrom) &&
    //   NodeTo.Equals(other.NodeTo) ||
    //   NodeFrom.Equals(other.NodeTo) &&
    //   NodeTo.Equals(other.NodeFrom)) &&
    //   Weight == other.Weight;
    //}

    public bool Equals(Edge other)
    {
        return
            (!(other is null) &&
             NodeFrom.Equals(other.NodeFrom) &&
             NodeTo.Equals(other.NodeTo) &&
             Weight == other.Weight);
    }
        /// <summary>
        /// The GraphEdge is compared on its NodeTo field.
        /// </summary>
        /// <returns>true = equal / false != equal</returns>
        public override bool Equals(object obj)
        {
            GraphEdge <T> edge = obj as GraphEdge <T>;

            if (edge != null)
            {
                return(NodeTo.Equals(edge.NodeTo));
            }
            else
            {
                return(false);
            }
        }