Example #1
0
        /// <summary>Compares SemanticGraphEdges.</summary>
        /// <remarks>
        /// Compares SemanticGraphEdges.
        /// Warning: compares on the sources, targets, and then the STRINGS of the relations.
        /// </remarks>
        /// <param name="other">Edge to compare to</param>
        /// <returns>Whether this is smaller, same, or larger</returns>
        public virtual int CompareTo(SemanticGraphEdge other)
        {
            int sourceVal = GetSource().CompareTo(other.GetSource());

            if (sourceVal != 0)
            {
                return(sourceVal);
            }
            int targetVal = GetTarget().CompareTo(other.GetTarget());

            if (targetVal != 0)
            {
                return(targetVal);
            }
            string thisRelation = GetRelation().ToString();
            string thatRelation = other.GetRelation().ToString();

            return(string.CompareOrdinal(thisRelation, thatRelation));
        }
Example #2
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (!(o is SemanticGraphEdge))
            {
                return(false);
            }
            SemanticGraphEdge semanticGraphEdge = (SemanticGraphEdge)o;

            if (relation != null)
            {
                bool retFlag  = relation.Equals(semanticGraphEdge.relation);
                bool govMatch = GetGovernor().Equals(semanticGraphEdge.GetGovernor());
                bool depMatch = GetDependent().Equals(semanticGraphEdge.GetDependent());
                bool matched  = retFlag && govMatch && depMatch;
                return(matched);
            }
            //   if (relation != null ? !relation.equals(semanticGraphEdge.relation) : semanticGraphEdge.relation != null) return false;
            return(base.Equals(o));
        }