Permalink
Browse files

inital commit

  • Loading branch information...
1 parent 1a8b261 commit 63433c7c38eb90cabff82e1ab9c35e9f8b8a3d1a @kalinbas committed May 18, 2016
Showing with 13,048 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +61 −0 viadf.sln
  3. +216 −0 viadflib/AStar/AStar.cs
  4. +35 −0 viadflib/AStar/Arc.cs
  5. +72 −0 viadflib/AStar/Graph.cs
  6. +74 −0 viadflib/AStar/Node.cs
  7. +69 −0 viadflib/AStar/Point2D.cs
  8. +878 −0 viadflib/AStar/PriorityQueue.cs
  9. +127 −0 viadflib/AStar/Track.cs
  10. +28 −0 viadflib/BoundingBox.cs
  11. +6 −0 viadflib/Data.cs
  12. +159 −0 viadflib/Data.dbml
  13. +147 −0 viadflib/Data.dbml.layout
  14. +3,388 −0 viadflib/Data.designer.cs
  15. +615 −0 viadflib/DataHandler.cs
  16. +202 −0 viadflib/Indexer.cs
  17. +10 −0 viadflib/PriceTypeEnum.cs
  18. +266 −0 viadflib/Program.cs
  19. +35 −0 viadflib/Properties/AssemblyInfo.cs
  20. +37 −0 viadflib/Properties/Settings.Designer.cs
  21. +14 −0 viadflib/Properties/Settings.settings
  22. +36 −0 viadflib/SearchParams.cs
  23. +44 −0 viadflib/SearchPosition.cs
  24. +290 −0 viadflib/SearchResult.cs
  25. +219 −0 viadflib/Searcher.cs
  26. +9 −0 viadflib/StatusEnum.cs
  27. +11 −0 viadflib/TravelTime/ITravelTimeDataProvider.cs
  28. +35 −0 viadflib/TravelTime/LatLng.cs
  29. +27 −0 viadflib/TravelTime/LatLngBounds.cs
  30. +112 −0 viadflib/TravelTime/SimplePriorityQueue.cs
  31. +90 −0 viadflib/TravelTime/TravelTimeAlgorithm.cs
  32. +10 −0 viadflib/TravelTime/TravelTimeDataConnection.cs
  33. +24 −0 viadflib/TravelTime/TravelTimeResult.cs
  34. +16 −0 viadflib/TypeEnum.cs
  35. +94 −0 viadflib/Utils.cs
  36. +183 −0 viadflib/ViaDFGraph.cs
  37. +88 −0 viadflib/ViaDfDataProvider.cs
  38. +8 −0 viadflib/app.config
  39. +4 −0 viadflib/packages.config
  40. +174 −0 viadflib/viadflib.csproj
  41. +148 −0 viadfweb/App_Start/RouteConfig.cs
  42. +21 −0 viadfweb/App_Start/WebApiConfig.cs
  43. +16 −0 viadfweb/Content/css/materialize.min.css
  44. +26 −0 viadfweb/Content/css/style.css
  45. +428 −0 viadfweb/Content/font/material-design-icons/LICENSE.txt
  46. BIN viadfweb/Content/font/material-design-icons/Material-Design-Icons.eot
  47. +769 −0 viadfweb/Content/font/material-design-icons/Material-Design-Icons.svg
  48. BIN viadfweb/Content/font/material-design-icons/Material-Design-Icons.ttf
  49. BIN viadfweb/Content/font/material-design-icons/Material-Design-Icons.woff
  50. BIN viadfweb/Content/font/material-design-icons/Material-Design-Icons.woff2
  51. BIN viadfweb/Content/font/roboto/Roboto-Bold.ttf
  52. BIN viadfweb/Content/font/roboto/Roboto-Bold.woff
  53. BIN viadfweb/Content/font/roboto/Roboto-Bold.woff2
  54. BIN viadfweb/Content/font/roboto/Roboto-Light.ttf
  55. BIN viadfweb/Content/font/roboto/Roboto-Light.woff
  56. BIN viadfweb/Content/font/roboto/Roboto-Light.woff2
  57. BIN viadfweb/Content/font/roboto/Roboto-Medium.ttf
  58. BIN viadfweb/Content/font/roboto/Roboto-Medium.woff
  59. BIN viadfweb/Content/font/roboto/Roboto-Medium.woff2
  60. BIN viadfweb/Content/font/roboto/Roboto-Regular.ttf
  61. BIN viadfweb/Content/font/roboto/Roboto-Regular.woff
  62. BIN viadfweb/Content/font/roboto/Roboto-Regular.woff2
  63. BIN viadfweb/Content/font/roboto/Roboto-Thin.ttf
  64. BIN viadfweb/Content/font/roboto/Roboto-Thin.woff
  65. BIN viadfweb/Content/font/roboto/Roboto-Thin.woff2
  66. BIN viadfweb/Content/img/Bld.png
  67. BIN viadfweb/Content/img/Blu.png
  68. BIN viadfweb/Content/img/Bsd.png
  69. BIN viadfweb/Content/img/Bsu.png
  70. BIN viadfweb/Content/img/Msd.png
  71. BIN viadfweb/Content/img/Msu.png
  72. BIN viadfweb/Content/img/Rld.png
  73. BIN viadfweb/Content/img/Rlu.png
  74. BIN viadfweb/Content/img/app.jpg
  75. BIN viadfweb/Content/img/b1.jpg
  76. BIN viadfweb/Content/img/b10.jpg
  77. BIN viadfweb/Content/img/b2.jpg
  78. BIN viadfweb/Content/img/b3.jpg
  79. BIN viadfweb/Content/img/b4.jpg
  80. BIN viadfweb/Content/img/b5.jpg
  81. BIN viadfweb/Content/img/b6.jpg
  82. BIN viadfweb/Content/img/b7.jpg
  83. BIN viadfweb/Content/img/b8.jpg
  84. BIN viadfweb/Content/img/b9.jpg
  85. BIN viadfweb/Content/img/bg_content.gif
  86. BIN viadfweb/Content/img/bg_eyecatcher.gif
  87. BIN viadfweb/Content/img/bg_header.gif
  88. BIN viadfweb/Content/img/fra.gif
  89. BIN viadfweb/Content/img/ger.gif
  90. BIN viadfweb/Content/img/google-play-badge.png
  91. BIN viadfweb/Content/img/hr.gif
  92. BIN viadfweb/Content/img/li_cube.gif
  93. BIN viadfweb/Content/img/map.png
  94. BIN viadfweb/Content/img/mex.gif
  95. BIN viadfweb/Content/img/mm_20_blue.png
  96. BIN viadfweb/Content/img/mm_20_red.png
  97. BIN viadfweb/Content/img/mm_20_shadow.png
  98. BIN viadfweb/Content/img/usa.gif
  99. BIN viadfweb/Content/img/zip-icon.png
  100. +4 −0 viadfweb/Content/js/main.js
  101. +9 −0 viadfweb/Content/js/materialize.min.js
  102. +58 −0 viadfweb/Content/search.js
  103. +54 −0 viadfweb/Controllers/AccountController.cs
  104. +295 −0 viadfweb/Controllers/AdminController.cs
  105. +24 −0 viadfweb/Controllers/ContentDeletedResult.cs
  106. +34 −0 viadfweb/Controllers/ControllerBase.cs
  107. +20 −0 viadfweb/Controllers/ErrorController.cs
  108. +294 −0 viadfweb/Controllers/HomeController.cs
  109. +32 −0 viadfweb/Controllers/PermanentRedirectResult.cs
  110. +102 −0 viadfweb/Controllers/SearchController.cs
  111. +205 −0 viadfweb/Controllers/ServiceController.cs
  112. +1 −0 viadfweb/Global.asax
  113. +19 −0 viadfweb/Global.asax.cs
  114. +19 −0 viadfweb/Models/AccountModels.cs
  115. +12 −0 viadfweb/Models/ColoniaRouteListModel.cs
  116. +92 −0 viadfweb/Models/CreateRouteModel.cs
  117. +12 −0 viadfweb/Models/DelegacionListModel.cs
  118. +12 −0 viadfweb/Models/MapModel.cs
  119. +21 −0 viadfweb/Models/MapResultModel.cs
  120. +12 −0 viadfweb/Models/RouteListModel.cs
  121. +15 −0 viadfweb/Models/RouteModel.cs
  122. +12 −0 viadfweb/Models/RoutePieceModel.cs
  123. +8 −0 viadfweb/Models/SmallSearchBoxModel.cs
  124. +34 −0 viadfweb/Properties/AssemblyInfo.cs
  125. +40 −0 viadfweb/Views/Account/LogOn.cshtml
  126. +137 −0 viadfweb/Views/Admin/AcceptarRuta.cshtml
  127. +344 −0 viadfweb/Views/Admin/CrearRuta.cshtml
  128. +17 −0 viadfweb/Views/Admin/FindDuplicates.cshtml
  129. +4 −0 viadfweb/Views/Admin/Index.cshtml
  130. +60 −0 viadfweb/Views/Admin/Routes.cshtml
  131. +5 −0 viadfweb/Views/Error/Error404.cshtml
  132. +4 −0 viadfweb/Views/Error/Index.cshtml
  133. +20 −0 viadfweb/Views/Home/AgregarRuta.cshtml
  134. +24 −0 viadfweb/Views/Home/Colonia.cshtml
  135. +24 −0 viadfweb/Views/Home/Condiciones.cshtml
  136. +32 −0 viadfweb/Views/Home/Delegacion.cshtml
  137. +299 −0 viadfweb/Views/Home/Index.cshtml
  138. +27 −0 viadfweb/Views/Home/OpenData.cshtml
  139. +35 −0 viadfweb/Views/Home/Privacidad.cshtml
  140. +139 −0 viadfweb/Views/Home/Route.cshtml
  141. +42 −0 viadfweb/Views/Home/RouteList.cshtml
  142. +48 −0 viadfweb/Views/Home/RoutePiece.cshtml
  143. +7 −0 viadfweb/Views/Home/RutaRegistrada.cshtml
  144. +30 −0 viadfweb/Views/Home/WebService.cshtml
  145. +41 −0 viadfweb/Views/Home/_RouteList.cshtml
  146. +15 −0 viadfweb/Views/Search/LastSearches.cshtml
  147. +13 −0 viadfweb/Views/Search/NotFound.cshtml
  148. +170 −0 viadfweb/Views/Search/Search.cshtml
  149. +9 −0 viadfweb/Views/Shared/_GoogleAnalytics.cshtml
  150. +144 −0 viadfweb/Views/Shared/_Layout.cshtml
  151. +12 −0 viadfweb/Views/Shared/_MobileResponsiveAd.cshtml
  152. +12 −0 viadfweb/Views/Shared/_MobileResponsiveAd2.cshtml
  153. +63 −0 viadfweb/Views/Shared/_SearchResultJS.cshtml
  154. +3 −0 viadfweb/Views/_ViewStart.cshtml
  155. +42 −0 viadfweb/Views/web.config
  156. +30 −0 viadfweb/Web.Debug.config
  157. +31 −0 viadfweb/Web.Release.config
  158. +88 −0 viadfweb/Web.config
  159. BIN viadfweb/favicon.ico
  160. +15 −0 viadfweb/packages.config
  161. +4 −0 viadfweb/robots.txt
  162. +293 −0 viadfweb/viadfweb.csproj
View
@@ -234,3 +234,7 @@ _Pvt_Extensions
# FAKE - F# Make
.fake/
+
+
+#Files for Webpage
+viadfweb/Content/files
View
@@ -0,0 +1,61 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "viadflib", "viadflib\viadflib.csproj", "{F0F895EB-46A3-4122-B3AA-298A84750897}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "viadfweb", "viadfweb\viadfweb.csproj", "{9B62E659-F1A0-420E-925F-EF6A581B77E9}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|Mixed Platforms = Debug|Mixed Platforms
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|Mixed Platforms = Release|Mixed Platforms
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Debug|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Debug|Mixed Platforms.Build.0 = Release|Any CPU
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Debug|x64.ActiveCfg = Debug|x64
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Debug|x64.Build.0 = Debug|x64
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Debug|x86.ActiveCfg = Debug|x86
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Debug|x86.Build.0 = Debug|x86
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Release|x64.ActiveCfg = Release|x86
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Release|x64.Build.0 = Release|x86
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Release|x86.ActiveCfg = Release|x86
+ {F0F895EB-46A3-4122-B3AA-298A84750897}.Release|x86.Build.0 = Release|x86
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Debug|x64.Build.0 = Debug|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Debug|x86.Build.0 = Debug|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Release|x64.ActiveCfg = Release|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Release|x64.Build.0 = Release|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Release|x86.ActiveCfg = Release|Any CPU
+ {9B62E659-F1A0-420E-925F-EF6A581B77E9}.Release|x86.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(TestCaseManagementSettings) = postSolution
+ CategoryFile = viadf.vsmdi
+ EndGlobalSection
+EndGlobal
@@ -0,0 +1,216 @@
+using System;
+using System.Collections.Generic;
+
+
+namespace viadflib.AStar
+{
+ /// <summary>
+ /// Class to search the best path between two nodes on a graph.
+ /// </summary>
+ public class AStar
+ {
+ Graph _Graph;
+ PriorityQueue _Open;
+ Dictionary<Node, double> _Closed;
+ int _NbIterations = -1;
+ int _NbResults = 1;
+ List<Track> _results;
+
+ private Node _startNode;
+ public Node StartNode {
+ get
+ {
+ return _startNode;
+ }
+ set
+ {
+ _startNode = value;
+ }
+ }
+
+ private Node _endNode;
+ public Node EndNode
+ {
+ get
+ {
+ return _endNode;
+ }
+ set
+ {
+ _endNode = value;
+
+ // calculate routepieceids which lead to the end node
+ RoutePieceIDArcsToEndNode = new Dictionary<int, Arc>();
+ foreach (Arc arc in EndNode.IncomingArcs)
+ {
+ RoutePieceIDArcsToEndNode.Add(arc.StartNode.RoutePieceID, arc);
+ }
+ }
+ }
+ public int NrOfFoundResults
+ {
+ get
+ {
+ return _results.Count;
+ }
+ }
+
+ public Dictionary<int, Arc> RoutePieceIDArcsToEndNode { get; set; }
+
+ public AStar(Graph G)
+ {
+ _Graph = G;
+ _Open = new PriorityQueue();
+ _Closed = new Dictionary<Node, double>();
+ }
+
+ public bool SearchPath(int nrOfResults)
+ {
+ Initialize();
+
+ _NbResults = nrOfResults;
+
+ while (NextStep()) { }
+ return PathFound;
+ }
+
+ private void Initialize()
+ {
+ if (StartNode == null || EndNode == null) throw new ArgumentNullException();
+ _Closed.Clear();
+ _Open.Clear();
+ _Open.Enqueue(new Track(StartNode, this));
+ _NbIterations = 0;
+ _NbResults = 1;
+ _results = new List<Track>();
+ }
+
+ private bool NextStep()
+ {
+ if (!Initialized) throw new InvalidOperationException("You must initialize AStar before launching the algorithm.");
+ if (_Open.Count == 0) return false;
+ _NbIterations++;
+
+ Track bestTrack = (Track)_Open.Dequeue();
+ if (bestTrack.Succeed)
+ {
+ if (!_results.Exists(x => x.IsDuplicate(bestTrack)))
+ {
+ _results.Add(bestTrack);
+ if (_results.Count >= _NbResults)
+ {
+ _Open.Clear();
+ }
+ }
+ }
+ else
+ {
+ Propagate(bestTrack);
+ }
+ return _Open.Count > 0;
+ }
+
+ private void Propagate(Track track)
+ {
+ double oldValue = double.MaxValue;
+ if (_Closed.ContainsKey(track.EndNode))
+ {
+ oldValue = _Closed[track.EndNode];
+ }
+
+ // only if new value is better - propagate
+ if (track.Evaluation < oldValue)
+ {
+ foreach (Arc arc in track.EndNode.OutgoingArcs)
+ {
+ Track successor = new Track(track, arc, this);
+ double oldValue2 = double.MaxValue;
+ if (_Closed.ContainsKey(arc.EndNode))
+ {
+ oldValue2 = _Closed[arc.EndNode];
+ }
+ if (track.Evaluation < oldValue2)
+ {
+ _Open.Enqueue(successor);
+ }
+ }
+
+ // only add track to end node when not in a change of transport
+ bool inChange = track.Queue != null && track.EndNode.RouteID != track.Queue.EndNode.RouteID;
+ if (!inChange && RoutePieceIDArcsToEndNode.ContainsKey(track.EndNode.RoutePieceID))
+ {
+ Track successor = new Track(track, RoutePieceIDArcsToEndNode[track.EndNode.RoutePieceID], this);
+ _Open.Enqueue(successor);
+ }
+ _Closed[track.EndNode] = track.Evaluation;
+ }
+ }
+
+ /// <summary>
+ /// To know if the search has been initialized.
+ /// </summary>
+ public bool Initialized { get { return _NbIterations >= 0; } }
+
+ /// <summary>
+ /// To know if the search has been started.
+ /// </summary>
+ public bool SearchStarted { get { return _NbIterations > 0; } }
+
+ /// <summary>
+ /// To know if the search has ended.
+ /// </summary>
+ public bool SearchEnded { get { return SearchStarted && _Open.Count == 0; } }
+
+ /// <summary>
+ /// To know if a path has been found.
+ /// </summary>
+ public bool PathFound { get { return _results.Count > 0; } }
+
+ /// <summary>
+ /// Use for a 'step by step' search only.
+ /// Gets the number of the current step.
+ /// -1 if the search has not been initialized.
+ /// 0 if it has not been started.
+ /// </summary>
+ public int StepCounter { get { return _NbIterations; } }
+
+ private void CheckSearchHasEnded()
+ {
+ if (!SearchEnded) throw new InvalidOperationException("You cannot get a result unless the search has ended.");
+ }
+
+ public Arc[] GetPathByArcs(int index)
+ {
+ CheckSearchHasEnded();
+ if (!PathFound) return null;
+ int Nb = _results[index].NbArcsVisited;
+ Arc[] Path = new Arc[Nb];
+ Track Cur = _results[index];
+ for (int i = Nb - 1; i >= 0; i--, Cur = Cur.Queue)
+ {
+ Path[i] = Cur.Queue.EndNode.ArcGoingTo(Cur.EndNode);
+ if (Path[i] == null)
+ {
+ foreach (Arc arc in Cur.EndNode.IncomingArcs)
+ {
+ if (arc.StartNode.RoutePieceID == Cur.Queue.EndNode.RoutePieceID) {
+ Path[i] = arc;
+ }
+ }
+
+ }
+ }
+ return Path;
+ }
+
+ public double Heuristic(Node from)
+ {
+ double distance = Node.ManhattanDistance(from, EndNode) / ViaDFGraph.KM_IN_DEGREES;
+ //double factor = distance < 0.5 ? 10 : distance > 10 ? 2.5 : (1 - (distance - 0.5) / (10 - 0.5)) * 7.5 + 2.5;
+
+ // assume overall average travel speed of 24 km/h
+ return 2.5 * distance;
+ }
+ }
+}
+
View
@@ -0,0 +1,35 @@
+using System;
+
+namespace viadflib.AStar
+{
+
+ [Serializable]
+ public class Arc
+ {
+ public Node StartNode { get; set; }
+ public Node EndNode { get; set; }
+ public double Cost { get; set; }
+
+ public Arc(Node startNode, Node endNode, double cost)
+ {
+ StartNode = startNode;
+ EndNode = endNode;
+ Cost = cost;
+ }
+
+ public override string ToString()
+ {
+ return StartNode + "-->" + EndNode;
+ }
+
+ public override bool Equals(object O)
+ {
+ Arc A = (Arc) O;
+ if ( A==null ) throw new ArgumentException("Cannot compare "+GetType()+" with "+O.GetType());
+ return StartNode.Equals(A.StartNode) && EndNode.Equals(A.EndNode);
+ }
+
+ public override int GetHashCode() { return StartNode.GetHashCode() + EndNode.GetHashCode(); }
+ }
+}
+
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+
+namespace viadflib.AStar
+{
+ [Serializable]
+ public class Graph
+ {
+ private List<Node> _nodeList;
+
+ public Graph()
+ {
+ _nodeList = new List<Node>();
+ }
+
+ public List<Node> Nodes { get { return _nodeList; } }
+
+ public void Clear()
+ {
+ _nodeList.Clear();
+ }
+
+ public bool AddNode(Node NewNode)
+ {
+ _nodeList.Add(NewNode);
+ return true;
+ }
+
+ public bool AddArc(Node StartNode, Node EndNode, double Cost)
+ {
+ Arc newArc = new Arc(StartNode, EndNode, Cost);
+ newArc.StartNode.OutgoingArcs.Add(newArc);
+ newArc.EndNode.IncomingArcs.Add(newArc);
+ return true;
+ }
+
+ public void Add2Arcs(Node Node1, Node Node2, double Cost)
+ {
+ AddArc(Node1, Node2, Cost);
+ AddArc(Node2, Node1, Cost);
+ }
+
+ public bool RemoveNode(Node NodeToRemove)
+ {
+ if (NodeToRemove == null) return false;
+ try
+ {
+ foreach (Arc a in NodeToRemove.IncomingArcs)
+ {
+ a.StartNode.OutgoingArcs.Remove(a);
+ }
+ foreach (Arc a in NodeToRemove.OutgoingArcs)
+ {
+ a.EndNode.IncomingArcs.Remove(a);
+ }
+ _nodeList.Remove(NodeToRemove);
+ }
+ catch { return false; }
+ return true;
+ }
+
+ public bool RemoveArc(Arc ArcToRemove)
+ {
+ if (ArcToRemove == null) return false;
+
+ ArcToRemove.StartNode.OutgoingArcs.Remove(ArcToRemove);
+ ArcToRemove.EndNode.IncomingArcs.Remove(ArcToRemove);
+
+ return true;
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 63433c7

Please sign in to comment.