diff --git a/Executable/Program.cs b/Executable/Program.cs index 9d94fe1..03dfbcb 100644 --- a/Executable/Program.cs +++ b/Executable/Program.cs @@ -13,8 +13,8 @@ do { do { - n1 = graph.nodes[r.Next(0, graph.nodes.Count - 1)]; - n2 = graph.nodes[r.Next(0, graph.nodes.Count - 1)]; + n1 = graph.GetNodeAtIndex(r.Next(0, graph.GetNodeCount() - 1)); + n2 = graph.GetNodeAtIndex(r.Next(0, graph.GetNodeCount() - 1)); _route = new Astar().FindPath(graph, n1, n2, logger); } while (!_route.routeFound); } while (Console.ReadKey().Key.Equals(ConsoleKey.Enter)); \ No newline at end of file diff --git a/Graph/Graph.cs b/Graph/Graph.cs index 74fa14f..8ec209e 100644 --- a/Graph/Graph.cs +++ b/Graph/Graph.cs @@ -3,7 +3,7 @@ namespace Graph { public class Graph { - public List nodes { get; } + private List nodes { get; } public Graph() { @@ -23,6 +23,16 @@ namespace Graph } } + public Node GetNodeAtIndex(int i) + { + return this.nodes[i]; + } + + public int GetNodeCount() + { + return this.nodes.Count; + } + public Node? GetNode(ulong id) { foreach(Node n in this.nodes) diff --git a/OpenStreetMap Importer/Importer.cs b/OpenStreetMap Importer/Importer.cs index f983c16..4e9b9f6 100644 --- a/OpenStreetMap Importer/Importer.cs +++ b/OpenStreetMap Importer/Importer.cs @@ -34,7 +34,7 @@ namespace OpenStreetMap_Importer mapData.Position = 0; logger?.Log(LogLevel.INFO, "Importing Graph..."); Graph.Graph _graph = CreateGraph(mapData, occuranceCount, onlyJunctions, logger); - logger?.Log(LogLevel.DEBUG, "Loaded Nodes: {0}", _graph.nodes.Count); + logger?.Log(LogLevel.DEBUG, "Loaded Nodes: {0}", _graph.GetNodeCount()); mapData.Close(); occuranceCount.Clear();