Giter Club home page Giter Club logo

map-generator's Introduction

Map generator

Generator of real-life like map for Engineering Distributed Infrastructure course at University of Warsaw. The project consists of designing, building and deploying a distributed application on a public cloud. Each team had an assigned Googler tutor who helped to scope the project; reviewed design documents and graded the final solution.

About project

The main goal of this project is to relatively fast generate large graph with a few assumptions. Graph has to be:

  • planar,
  • weighted,
  • sparse,
  • provide 2D layout of vertices,
  • similar to google map

Every vertex represents crossroad and edge is a two-way street.

Map partition

  • 512 x 512 regions
  • every region is 320 x 320 units
  • point coordinates are integers
  • for every region, there is randomized type of village with certain probability
  • for every village, there is randomized number of crossroads according to village type
  • expected number of points in a village is 45
  • expected number of points on the map is 11 796 480

Estimation of density and distribution of points

As a model I took the demographics of Poland and populated map to look like Poland

Population Number of such villages Estimation of number of crossroads
1M - 2M 1 10.000 - 30.000
500k - 1M 5 5000 - 10.000
200k - 500k 10 3000 - 5000
100k - 200k 25 2000 - 4000
20k - 100k 200 500 - 2000
10k - 20k 200 200 - 500
2k - 10k 600 50 - 200
10 - 2000 30.000 5 - 50

Distribution of points inside region

  • expected density is between ⅓ - ⅙
  • inside given region, we choose rectangular area and recursivelt shorten it
  • as we achieve area with satisfying size, we randomly generate points and edges

Connecting points inside regions

Euclidean minimum spanning tree:

  • Delaunay triangulation
  • Union–find data structure

As we want to add extra edges, we modified Union-find data structure as follows:

  • if two points a and b are in distincts sets, we add edge between them
  • if two points a and b are in the same sets, we add edge between them with probability ¼

Connecting regions

To avoid keeping 10^7 vertices and about 3 * 10^7 edges (which is about 1GB of data) we do as follows:

  • save all region's verices and edges to file
  • we compute convex hull and we keep in memory only vertices on it
  • now we connect all regions in similar way as we connevted points inside regions and for two regions to connect we select the closest points on convex hulls of those regions

Visualization of distribution of points in 64x64 regions:

map-generator's People

Contributors

foginthefrog avatar

Stargazers

Aleksandra Daniluk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.