Exemplo n.º 1
0
        /// <summary>
        /// Load edges from file
        /// </summary>
        /// <param name="filePath"></param>
        public static void LoadEdges(IGraph graph, string filePath)
        {
            var reader = new StreamReader(File.OpenRead(filePath));

            while (!reader.EndOfStream)
            {
                var connection = reader.ReadLine().Split(',');

                var fromNode = graph.Nodes[connection[0]];
                var toNode   = graph.Nodes[connection[1]];

                var distance = 0;
                int.TryParse(connection[2], out distance);

                graph.AddConnection(fromNode, toNode, distance);
            }
        }
Exemplo n.º 2
0
 public void AddRoute(Academy from, Academy to, int distance)
 {
     Graph.AddConnection(new Node <Academy>(from, from.Name),
                         new Node <Academy>(to, to.Name),
                         distance);
 }