Exemplo n.º 1
0
        /// <summary>
        /// Returns de sumatory of cost vertex
        /// </summary>
        /// <param name="route"></param>
        /// <returns>distance</returns>
        public string getDistance(string route)
        {
            string distance = string.Empty;
            clsEdge edge = new clsEdge();
            float total = 0;
            List<clsEdge> edges = new List<clsEdge>();
            for (int i = 0; i < route.Length - 1; i++)
            {
                edge = this.lstVertex.Where(x => x.Name.Equals(route[i].ToString())).FirstOrDefault().lstEdge.Where(x => x.Vertex2.Equals(route[i + 1])).FirstOrDefault();

                if (edge != null)
                {
                    edges.Add(edge);
                    total += edge.Cost;
                }
                else
                {
                    distance = "NO SUCH ROUTE";
                    break;
                }
                distance = total.ToString();
            }

            return distance;
        }
Exemplo n.º 2
0
 public void addEdge(clsEdge oEdge)
 {
     this.lstVertex.Where(x => x.Name.Equals(oEdge.Vertex1.ToString())).FirstOrDefault().lstEdge.Add(oEdge);
 }