Giter Club home page Giter Club logo

simulatinghyperbolicgraphs's Introduction

Simulating Hyperbolic Graphs

Python simulation for generating hyperbolic graphs.

Great video for understanding hyperbolic random graphs: https://www.youtube.com/watch?v=JfqC-e6JsVk

Dependencies

python package network2tikz is used: pip install network2tikz

and tikzplotlib: pip install tikzplotlib

the latex output depends on tikz-network, download the .sty here: https://mirror.lyrahosting.com/CTAN/graphics/pgf/contrib/tikz-network/tikz-network.sty

Setting

Consider a Hyperbolic Random Graph with parameters alpha, v, n. Here n is number of vertices, v average degree in network, -alpha the negative curvature.

  • the random graph has n vertices placed on disk in hyperbolic space randomly.
  • The disk has radius R = 2log(n/v)
  • radius-density follows :p(r) = alpha * (frac{sinh(alphar)}{cosh(alphaR)-1}), where 0 < r < R, 0 otherwise.
    • recall that the area of the disc increases exponentially over the Radius in hyperoblic space (as opposed to R^2 in euclidian). So we expect most points to be closer to further away from center.

Approach

  • generate n vertices by sampling random vector of (r, theta) (as by polar coordinates)
    • theta is distibuted uniformly from [0, 2pi]
    • r follows density p(r)
  • loop through all points, and let them share edge if its hyperbolic distance is at most R.
    • this distance x is given by the hyperbolic law of cosines
    • cos(x) = cosh(r) cosh(r') − sinh(r) sinh(r')cos(φ − φ') for points (r, φ), (r', φ').
  • draw and save the generated graph on plot (in euclidian).
  • plot degree distribution.

Expected Results

for a vertex at radius r_i, we expect it's degree to be around e^(R-r_i)/2 (exp value of poisson distr. of its type.)

How To Use

See the ExampleUsage.py for straightforward implementation.

Example Output

Using v (averagedegrees) = 1, n (number of nodes) = 250, alpha (negative curvature) = 0.6, we obtain the following random graph: Example of random graph

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.