public override bool DeleteEdge(T v1, T v2) { if (v1 is null) { throw new ArgumentNullException(nameof(v1)); } if (v2 is null) { throw new ArgumentNullException(nameof(v2)); } IPairValue <T> pair_1 = new PairValueI <T>(v1, v2); IPairValue <T> pair_2 = new PairValueI <T>(v2, v1); if (EdgeSet.Contains(pair_1) || EdgeSet.Contains(pair_2)) { EdgeSet.Remove(pair_1); Weights.Remove(pair_1); EdgeSet.Remove(pair_2); Weights.Remove(pair_2); return(true); } return(false); }
public override bool AddEdge(T v1, T v2, K weight) { if (v1 is null) { throw new ArgumentNullException(nameof(v1)); } if (v2 is null) { throw new ArgumentNullException(nameof(v2)); } if (weight is null) { throw new ArgumentNullException(nameof(weight)); } if (!VertexSet.Contains(v1) || !VertexSet.Contains(v2)) { return(false); } IPairValue <T> pair = new PairValueI <T>(v1, v2); if (EdgeSet.Contains(pair)) { return(false); } EdgeSet.Add(pair); Weights[pair] = weight; return(true); }
public override bool AreAdjacent(TV v1, TV v2) { if (v1 == null || v2 == null) { throw new ArgumentNullException(); } if (!VertexSet.Contains(v1) || !VertexSet.Contains(v2)) { throw new ArgumentException(); } return(EdgeSet.Contains(new PairValue <TV>(v1, v2))); }
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); }
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); }
public override bool AreAdjacent(T v1, T v2) { if (v1 is null) { throw new ArgumentNullException(nameof(v1)); } if (v2 is null) { throw new ArgumentNullException(nameof(v2)); } if (!VertexSet.Contains(v1) || !VertexSet.Contains(v2)) { throw new ArgumentException(); } return(EdgeSet.Contains(new PairValueI <T>(v1, v2))); }
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); }
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); }