public override bool Equals(object o)
        {
            if (o == null || o.GetType() != typeof(PairValue <T>))
            {
                return(false);
            }
            PairValue <T> casted = (PairValue <T>)o;

            return(casted._t1.Equals(_t1) && casted._t2.Equals(_t2));
        }
示例#2
0
        public override TK GetWeigth(TV v1, TV v2)
        {
            if (v1 == null || v2 == null)
            {
                throw new ArgumentNullException();
            }
            IPairValue <TV> pair = new PairValue <TV>(v1, v2);

            if (!Weigths.ContainsKey(pair))
            {
                throw new ArgumentException();
            }
            return(Weigths[pair]);
        }
示例#3
0
        public override K GetWeight(T v1Key, T v2Key)
        {
            if (v1Key == null || v2Key == null)
            {
                throw new ArgumentNullException();
            }
            IPairValue <T> pair = new PairValue <T>(v1Key, v2Key);

            if (!Weights.ContainsKey(pair))
            {
                throw new ArgumentException();
            }

            return(Weights[pair]);
        }
示例#4
0
        public override bool DeleteEdge(TV v1, TV v2)
        {
            if (v1 == null || v2 == null)
            {
                throw new ArgumentNullException();
            }
            IPairValue <TV> pair = new PairValue <TV>(v1, v2);

            if (EdgeSet.Contains(pair))
            {
                EdgeSet.Remove(pair);
                Weigths.Remove(pair);
                return(true);
            }
            return(false);
        }
示例#5
0
        public override bool Equals(object?obj)
        {
            bool isEqual = false;

            if (obj == null || obj.GetType() != typeof(PairValue <T>))
            {
                isEqual = false;
            }
            PairValue <T> casted = (PairValue <T>)obj;

            if (casted._t1.Equals(_t1) && casted._t2.Equals(_t2))
            {
                isEqual = true;
            }
            return(isEqual);
        }
示例#6
0
        public override bool AddEdge(T v1, T v2, K weight)
        {
            bool isAdded = false;

            if (v1 == null || v2 == null || weight == null)
            {
                throw new ArgumentNullException();
            }
            if (Vertices.Contains(v1) && Vertices.Contains(v2))
            {
                var pair = new PairValue <T>(v1, v2);
                Edges.Add(pair);
                Weights[pair] = weight;
                isAdded       = true;
            }
            return(isAdded);
        }
示例#7
0
        public override bool DeleteEdge(T v1Key, T v2Key)
        {
            if (v1Key == null || v2Key == null)
            {
                throw new ArgumentNullException();
            }

            IPairValue <T> pair = new PairValue <T>(v1Key, v2Key);

            if (EdgeSet.Contains(pair))
            {
                EdgeSet.Remove(pair);
                Weights.Remove(pair);
                return(true);
            }

            return(false);
        }
示例#8
0
        public override bool AddEdge(TV v1, TV v2, TK weigth)
        {
            if (v1 == null || v2 == null || weigth == null)
            {
                throw new ArgumentNullException();
            }
            if (!VertexSet.Contains(v1) || !VertexSet.Contains(v2))
            {
                return(false);
            }
            IPairValue <TV> pair = new PairValue <TV>(v1, v2);

            if (EdgeSet.Contains(pair))
            {
                return(false);
            }
            EdgeSet.Add(pair);
            Weigths[pair] = weigth;
            return(true);
        }
示例#9
0
        public override bool AddEdge(KeyValuePair <T, K> v1, KeyValuePair <T, K> v2, K weight)
        {
            if (v1.Key == null || v2.Key == null || weight == null)
            {
                throw new ArgumentNullException();
            }
            if (!VertexSet.Contains(v1) || !VertexSet.Contains(v2))
            {
                return(false);
            }
            IPairValue <T> pair = new PairValue <T>(v1.Key, v2.Key);

            if (EdgeSet.Contains(pair))
            {
                return(false);
            }

            EdgeSet.Add(pair);
            Weights[pair] = weight;
            return(true);
        }