Esempio n. 1
0
        public void AddEdge(int source, int dest, double cost)
        {
            Vertex <TValue> sourceVertex = GetVertex(source);
            Vertex <TValue> destVertex   = GetVertex(dest);

            sourceVertex.AddEdge(destVertex, cost);
        }
Esempio n. 2
0
        public void AddEdge(Vertex partner, int weight)
        {
            Edges.Add(new Edge(this, partner, weight));

            if (!partner.Edges.Contains(Edges.LastOrDefault()))
            {
                partner.AddEdge(Edges.LastOrDefault());
            }
        }
Esempio n. 3
0
 public void AddEdge(Vertex v1, Vertex v2)
 {
     if (!HasVertex(v1))
     {
         AddVertex(v1);
     }
     if (!HasVertex(v2))
     {
         AddVertex(v2);
     }
     v1.AddEdge(v2);
 }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
 public void LinkVertex(Vertex v1, Vertex v2, int weight)
 {
     v1.AddEdge(v2, weight);
     Edges.Add(v1.Edges.LastOrDefault());
 }
Esempio n. 6
0
 public void LinkVertex(Vertex v1, Vertex v2)
 {
     v1.AddEdge(v2);
     Edges.Add(v1.Edges.LastOrDefault());
 }