public void AddEdge(int source, int dest, double cost) { Vertex <TValue> sourceVertex = GetVertex(source); Vertex <TValue> destVertex = GetVertex(dest); sourceVertex.AddEdge(destVertex, cost); }
public void AddEdge(Vertex partner, int weight) { Edges.Add(new Edge(this, partner, weight)); if (!partner.Edges.Contains(Edges.LastOrDefault())) { partner.AddEdge(Edges.LastOrDefault()); } }
public void AddEdge(Vertex v1, Vertex v2) { if (!HasVertex(v1)) { AddVertex(v1); } if (!HasVertex(v2)) { AddVertex(v2); } v1.AddEdge(v2); }
public void AddEdge(Vertex start, Vertex end, int weight) { Assert.ArgumentNotNull(start, nameof(start)); Assert.ArgumentNotNull(end, nameof(end)); this.ValidateIfVertexExist(start); this.ValidateIfVertexExist(end); // Two vertices must be unique. if (start == end) { throw new ArgumentException($"An edge cannot be added between the single vertex '{start.Name}'."); } start.AddEdge(new Edge(weight, end)); end.AddEdge(new Edge(weight, start)); }
public void LinkVertex(Vertex v1, Vertex v2, int weight) { v1.AddEdge(v2, weight); Edges.Add(v1.Edges.LastOrDefault()); }
public void LinkVertex(Vertex v1, Vertex v2) { v1.AddEdge(v2); Edges.Add(v1.Edges.LastOrDefault()); }