{"id":16455108,"url":"https://github.com/lucadibello/geographical-friendship-network","last_synced_at":"2026-06-12T12:31:14.814Z","repository":{"id":205675616,"uuid":"710655703","full_name":"lucadibello/geographical-friendship-network","owner":"lucadibello","description":"Simulation of a social network formation influenced by geographical features and distance","archived":false,"fork":false,"pushed_at":"2023-11-05T22:55:21.000Z","size":95897,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-26T22:30:48.839Z","etag":null,"topics":["erdos-renyi","friendship-network","probabilistic-models","social-network"],"latest_commit_sha":null,"homepage":"https://nbviewer.org/github/lucadibello/geographical-friendship-network/blob/main/geographical-friendship-network.ipynb","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucadibello.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-27T06:48:38.000Z","updated_at":"2024-09-09T07:35:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"ba53386b-8c74-4ad8-9d57-6bc8e043bfa2","html_url":"https://github.com/lucadibello/geographical-friendship-network","commit_stats":null,"previous_names":["lucadibello/geographical-friendship-network"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lucadibello/geographical-friendship-network","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucadibello%2Fgeographical-friendship-network","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucadibello%2Fgeographical-friendship-network/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucadibello%2Fgeographical-friendship-network/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucadibello%2Fgeographical-friendship-network/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucadibello","download_url":"https://codeload.github.com/lucadibello/geographical-friendship-network/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucadibello%2Fgeographical-friendship-network/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34245217,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["erdos-renyi","friendship-network","probabilistic-models","social-network"],"created_at":"2024-10-11T10:21:07.702Z","updated_at":"2026-06-12T12:31:14.789Z","avatar_url":"https://github.com/lucadibello.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Geographical-based friendship network\u003c!-- omit in toc--\u003e\n\nLuca Di Bello, University of Italian Switzerland (USI), 2023\n\n## Showcase\u003c!-- GIFS --\u003e\n\n\u003ctable style=\"width:100%\"\u003e\n  \u003ctr\u003e\n    \u003cth\u003ePurely random friendship network\u003c/th\u003e\n    \u003cth\u003eGeographical-based friendship network\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n      \u003cimg src=\"./assets/showcase/edoz-renyi-simulation-optimized.gif\" width=\"auto\" /\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003cimg src=\"./assets/showcase/geographical-simulation-optimized.gif\" width=\"auto\" /\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003e Note: The GIFs above are just a small sample of the pre-computed simulations. The full set of simulations can be found in the `assets` folder or in the *Jupyter Notebook* project.\n\n## Table of contents\u003c!-- omit in toc--\u003e\n\n- [Geographical-based friendship network](#geographical-based-friendship-network)\n  - [Showcase](#showcase)\n  - [Table of contents](#table-of-contents)\n  - [Project description](#project-description)\n  - [Inhabitant maps](#inhabitant-maps)\n    - [Purely random map](#purely-random-map)\n    - [Geographical-based random map](#geographical-based-random-map)\n  - [Friendship networks](#friendship-networks)\n  - [Project](#project)\n  - [Getting started](#getting-started)\n\n## Project description\n\nSocial networks are systems that map the relationships and interactions between individuals. Although social networks are typically dynamic, the focus of this project is put on a static example.\n\nGeographical distance plays a crucial role in social network formation, with closer physical proximity typically leading to more frequent and stronger social ties.\n\nAdditionally, geographical features, such as the density of people in an area (more in cities and less in remote mountainous regions), profoundly influence the composition and scale of these networks, shaping the diversity and connectivity of communities within a given region.\n\n## Inhabitant maps\n\nThe project features two kinds of inhabitant maps:\n\n### Purely random map\n\n1000 inhabitants are randomly distributed across a unit square map, $[0,1]^2$. Each individual is assigned a uniform random position $(x,y)$ in the map.\n\n### Geographical-based random map\n\nThis map features several geographical areas $F$, such as cities, mountains, and lakes. The inhabitants are randomly distributed across the map, but the density of inhabitants is higher in cities and lower in mountains and lakes. The function $f$ maps the coordinates $(x, y)$ of an individual to the geographical area $f$ in which the individual is located.\n\n$$\nf(x,y) = \\text{geographical area in which individual } (x,y) \\text{ is located}\n$$\n\nIn this map, individuals are no longer distributed uniformly at random across the map. Instead, the density of inhabitants depends on specific geographical features: each area has a positive factor that determines the ease of living there:\n\n$$\n\\begin{equation*} \\tag{1}\ns_f = \\text{ease of living in area } f \\ \\forall f \\in F\n\\end{equation*}\n$$\n\nThe probability of a random individual being located in coordinates $(x,y)$ is the following:\n\n$$\n\\begin{equation} \\tag{2}\nP(\\text{random person settles in } (x,y)) = \\frac{s_{f(x,y)}}{\\sum_{(x',y') \\in \\text{Map}} s_{f(x',y')}}\n\\end{equation}\n$$\n\n## Friendship networks\n\nFrom the inhabitant maps, a friendship network is created following two different models:\n\n**Map 1 - Erdős–Rényi model**: The friendships are modeled as an *Erdős–Rényi* random graph. Each individual has a probability $p$ of being friends with another individual, and this probability $p$ is identical for all possible pairs of individuals\n\n**Map 2 - Geographical model**: The probability of a friendship between two individuals A and B is modeled as follows:\n\n$$\n\\begin{equation*} \\tag{3}\nP(A - B) = e^{-\\beta\\ d(A,B)}\n\\end{equation*}\n$$\n\nWhere $d(A,B)$ is the Euclidean distance between $A$ and $B$ and $\\beta$ is a parameter that determines the strength of the geographical effect. The higher the value of $\\beta$, the more likely it is that two individuals will be friends if they are close to each other.\n\n## Project\n\nThe project is available as a *Jupyter Notebook* and can be found [here](https://nbviewer.org/github/lucadibello/geographical-friendship-network/blob/main/geographical-friendship-network.ipynb) (nbviewer.org).\n\n\u003e Alternatively, the notebook can be viewed directly on GitHub [here](./notebooks/geographical-friendship-network.ipynb).\n\n## Getting started\n\nIt is advised to use the provided *environment.yml* file to create a new *conda* environment with all the required dependencies by executing the following command:\n\n```bash\nconda env create -f environment.yml\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucadibello%2Fgeographical-friendship-network","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucadibello%2Fgeographical-friendship-network","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucadibello%2Fgeographical-friendship-network/lists"}