/// <summary> /// Build fixed edges given in tsp file /// </summary> /// <param name="nodes">graph nodes</param> /// <returns>List of fixed edges</returns> protected List <IEdge> LoadFixedEdges(IEnumerable <INode> nodes) { NodesCollection graphNodes = new NodesCollection(nodes); List <IEdge> result = new List <IEdge>(); if (tspFile.FixedEdges != null) { foreach (int[] entry in tspFile.FixedEdges) { if (entry[0] == -1) { break; } result.Add(new Edge(graphNodes.FindById(entry[0]), graphNodes.FindById(entry[1]))); } } return(result); }
/// <summary> /// Loads demands for graph nodes /// </summary> /// <param name="nodes">all nodes in graph</param> /// <returns>demands for graph nodes</returns> protected Dictionary <INode, int> LoadDemands(IEnumerable <INode> nodes) { NodesCollection graphNodes = new NodesCollection(nodes); Dictionary <INode, int> result = new Dictionary <INode, int>(); foreach (int[] entry in tspFile.Demands) { result.Add(graphNodes.FindById(entry[0]), entry[1]); } return(result); }
/// <summary> /// Loads nodes that are depots /// </summary> /// <param name="nodes">all nodes in graph</param> /// <returns>Nodes that are depots</returns> protected List <INode> LoadDepots(IEnumerable <INode> nodes) { NodesCollection graphNodes = new NodesCollection(nodes); NodesCollection result = new NodesCollection(); foreach (int id in tspFile.Depots) { result.Add(graphNodes.FindById(id)); } return(result.ToList()); }
/// <summary> /// Build fixed edges given in tsp file /// </summary> /// <param name="nodes">graph nodes</param> /// <returns>List of fixed edges</returns> protected List<IEdge> LoadFixedEdges(IEnumerable<INode> nodes) { NodesCollection graphNodes = new NodesCollection(nodes); List<IEdge> result = new List<IEdge>(); if (tspFile.FixedEdges != null) { foreach (int[] entry in tspFile.FixedEdges) { if (entry[0] == -1) { break; } result.Add(new Edge(graphNodes.FindById(entry[0]), graphNodes.FindById(entry[1]))); } } return result; }
/// <summary> /// Loads demands for graph nodes /// </summary> /// <param name="nodes">all nodes in graph</param> /// <returns>demands for graph nodes</returns> protected Dictionary<INode, int> LoadDemands(IEnumerable<INode> nodes) { NodesCollection graphNodes = new NodesCollection(nodes); Dictionary<INode, int> result = new Dictionary<INode, int>(); foreach (int[] entry in tspFile.Demands) { result.Add(graphNodes.FindById(entry[0]), entry[1]); } return result; }
/// <summary> /// Loads nodes that are depots /// </summary> /// <param name="nodes">all nodes in graph</param> /// <returns>Nodes that are depots</returns> protected List<INode> LoadDepots(IEnumerable<INode> nodes) { NodesCollection graphNodes = new NodesCollection(nodes); NodesCollection result = new NodesCollection(); foreach (int id in tspFile.Depots) { result.Add(graphNodes.FindById(id)); } return result; }