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); }
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); }
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); }
public int GetHashCode(ClusterEdge <T> obj) { return(_clusterComparer.GetHashCode(obj.Source) ^ _clusterComparer.GetHashCode(obj.Target) ^ obj.Length.GetHashCode()); }