From 0e621e316bfbb9e2b4f49d717c7c1b0b8b5f94f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Engstr=C3=B6m?= <123507241+alexandengstrom@users.noreply.github.com> Date: Sat, 11 May 2024 13:38:49 +0200 Subject: [PATCH] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cf01c94..ff4fd87 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,11 @@ If the `-j` flag i used, the output will be in JSON-format: - Edges: A list of edge objects, each describing a connection between two nodes and containing: **u**: An object with properties **x** and **y**, representing the starting node's coordinates, **v**: An object with properties **x** and **y**, representing the ending node's coordinates and **weight**: The weight of the edge, indicating the cost or distance. ## Algorithm -The generator begins by creating a graph structure where different city types are instantiated with predefined properties based on their size and importance. Cities are placed randomly within a defined area while ensuring they maintain a minimum distance from each other to avoid overlap. The backbone of the network is formed by connecting major cities (metropolises and urban centers) with highways. These connections are designed to simulate main traffic routes and are the first to be laid out. The generator ensures these connections make geographical sense and avoid unnecessary detours. Once the primary connections are established, the generator begins to incorporate towns, villages, and hamlets. These smaller cities are connected to the nearest larger cities or directly to the highway system, using minor roads. At last last we delete all unnecessary nodes in the graph, this means all nodes which have just two neighbours and doesnt have a special meaning. After that we make sure the graph is connected and if not we add some extra edges. +The generator begins by creating a graph structure where different city types are instantiated with predefined properties based on their size and importance. Cities are placed randomly within a defined area while ensuring they maintain a minimum distance from each other to avoid overlap. The backbone of the network is formed by connecting major cities (metropolises and urban centers) with highways. These connections are designed to simulate main traffic routes and are the first to be laid out. The generator ensures these connections make geographical sense and avoid unnecessary detours. Once the primary connections are established, the generator begins to incorporate towns, villages, and hamlets. These smaller cities are connected to the nearest larger cities or directly to the highway system, using minor roads. + +At this stage. The map will be divided into squares. The current config is to create a 10x10 grid and place all cities, villages etc in one of these squares. Then we create one more connections from each square to its neighbour squares. This is because we want to avoid smaller villages being close to each other but have a very long road to reach each other. At this stage there is a difference when using the `-x` flag. If the flag is not used, we will pick a random point from the first square and then search for the closest point in the second square, resulting in a time complexity of $O(n)$. If the flag is used we will make sure we find the closest pair from both squares resulting in a time complexity of $O(n^2)$. + +At last last we delete all unnecessary nodes in the graph, this means all nodes which have just two neighbours and doesnt have a special meaning. After that we make sure the graph is connected and if not we add some extra edges. The roads in the network are assigned costs based on their type and importance. The highways will have lower cost than streets or rural roads. There is five different kind of roads in the graph. These are highways, main roads, minor roads, rural roads, slow roads and streets.