GithubHelp home page GithubHelp logo

doc22940 / thepandemichack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from f0lg0/thepandemichack

0.0 0.0 0.0 1.25 MB

Social distancing visualized with an undirected graph and Dijkstra Algorithm

Home Page: https://the-pandemic-hack.now.sh

License: MIT License

JavaScript 54.11% HTML 41.42% CSS 4.47%

thepandemichack's Introduction

The Pandemic Hack

This is a small project where I wanted to apply my newly learned knowledge on DataStructures and Javascript.
The goal is to underline the importance of social distancing during a pandemic.


Requirements

  • NodeJS
  • npm (node package manager)
  • Express
  • json2csv

Run

Dependencies

NodeJS and npm

Check your installations in a terminal window with:

node -v
npm -v

it should be enough doing:

npm install

to install everything you need, in case of need try to manually install these packages:

npm install express
npm install json2csv

The package.json should be already present in the "src" folder.

Run the project

I recommend you to start the server which is needed only if you want to land on the home page of the project with an explanation:

node server.js

and then visit http://localhost:8080

Please take a look there, you will find some documentation on the project.

Running your own simulation

There's some pre-compiled data in this project, which means I've already run a simulation and built the network of individuals. It is just an example with the alphabet letters, you can easily start your own by following these steps.

Modify only the main.js file inside the "core" folder. At line 10 you will find:

let name_set = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

Modify this and add your own individuals of the network.

Modify:

max_conn_number = 1;

If you want to add more random connections for each node.
Note that the value is 1 by default but it doesn't mean that every node has only one connection!

Change the range in:

connected = graph.addEdge(population[i], possible_conenctions[candidate_indx], Math.floor(Math.random() * 5) + 1);

If you want to modify the weight of the edges (links or connections), higher value means less frequent contact between individuals which also means a longer period of infection for the disease.

Finally run

node ./core/main.js

It will run the simulation involving creating an undirected graph and traversing the shortest path with Dijkstra Algorithm. Make sure to read the documentation by starting the server!

Result

The code will generate a file called "social-net.json" and eventually "[PLOT]social-net.json" if you decide to run the convert_data function when prompted to do so, which re-organizes your newly created JSON network for plotting. The plot.js file works with this kind of format.

These files represent the network of individuals with their respective edges. The "PLOT" is just a more polished data set for plotting.
Note that the visualization on the landing page is pretty simple. Nothing really fancy going on there. I'm very new to web development!

The simulation also generates a result.csv file where you will find all the results from all the simulations you run, it consits of the shortes path and the total distance.. It is plotted at http://localhost/results using chart.js!

If you want to visualize your own file generated with this app then visit http://localhost:8080/upload

Notes

The landing page is optimized for "half window" reading.

Virus icons made by https://www.flaticon.com/authors/freepik from https://www.flaticon.com/, full repo icon by me.

Code for graph visualization taken from https://bl.ocks.org/mbostock/2675ff61ea5e063ede2b5d63c08020c7 and adapted to my project by me.

More stuff

The study I am currently following for the second half of the project is located in the documentation folder.

In there you will also find a small explaination of the Dijkstra Algorithm made by me.

thepandemichack's People

Contributors

f0lg0 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.