Пример #1
0
            public int GetHashCode(ClusterEdge <T> obj)
            {
                int code = 23;

                code = code * 31 + _clusterComparer.GetHashCode(obj.Source);
                code = code * 31 + _clusterComparer.GetHashCode(obj.Target);
                code = code * 31 + obj.Length.GetHashCode();
                return(code);
            }
Пример #2
0
        private double CalcSequenceWeights(IBidirectionalGraph <Cluster <TSeq>, ClusterEdge <TSeq> > tree, ClusterEdge <TSeq> edge, double curWeight,
                                           Stack <Cluster <TSeq> > nodeStack, Dictionary <Cluster <TSeq>, Profile <TSeq, TItem> > profiles)
        {
            double length = edge.Length;

            if (tree.IsOutEdgesEmpty(edge.Target))
            {
                TSeq   seq    = edge.Target.DataObjects.First();
                double weight = curWeight + length;
                profiles[edge.Target] = CreateProfile(seq, weight);
                return(weight);
            }

            nodeStack.Push(edge.Target);
            double lengthPart = length / tree.OutDegree(edge.Target);
            double maxWeight  = double.MinValue;

            foreach (ClusterEdge <TSeq> childEdge in tree.OutEdges(edge.Target))
            {
                maxWeight = Math.Max(maxWeight, CalcSequenceWeights(tree, childEdge, curWeight + lengthPart, nodeStack, profiles));
            }
            return(maxWeight);
        }
Пример #3
0
 public bool Equals(ClusterEdge <T> x, ClusterEdge <T> y)
 {
     return(_clusterComparer.Equals(x.Source, y.Source) && _clusterComparer.Equals(x.Target, y.Target) &&
            Math.Abs(x.Length - y.Length) < double.Epsilon);
 }
Пример #4
0
 public int GetHashCode(ClusterEdge <T> obj)
 {
     return(_clusterComparer.GetHashCode(obj.Source) ^ _clusterComparer.GetHashCode(obj.Target) ^ obj.Length.GetHashCode());
 }