Giter VIP home page Giter VIP logo

cshvienna / networkinequalities Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 1.0 70.35 MB

Repository of the netin package to generate random scale-free graph generators proposed by members of the Network Inequality CSH group.

Home Page: https://cshvienna.github.io/NetworkInequalities/

License: Other

Python 37.51% CSS 1.65% HTML 60.84%
graph-generator homophily networks random-graphs scale-free-networks triadic-closure

networkinequalities's Introduction

NetIn

NetworkInequality

NetIn is a python package for network inference. It is based on the NetworkX package and provides a set of methods to study network inequalities. The package is currently under development and will be updated regularly.

https://static.pepy.tech/personalized-badge/netin?period=total&units=international_system&left_color=black&right_color=orange&left_text=Downloads

Simple examples

Create an undirected network with preferential attachment and homophily.

>>> from netin import PAH
>>> G = PAH(n=200, k=2, f_m=0.2, h_MM=0.1, h_mm=0.9, seed=42)
>>> G.generate()
>>> G.info()

Create a directed network with preferential attachment and homophily.

>>> from netin import DPAH
>>> G = DPAH(n=200, f_m=0.2, d=0.02, h_MM=0.1, h_mm=0.6, plo_M=2.0, plo_m=2.0, seed=42)
>>> G.generate()
>>> G.info()

Install

Install the latest version of NetIn:

$ pip install netin

Install from source:

$ git clone
$ cd NetworkInequalities
$ pip install -e .

Bugs

Please report any bugs that you find here. Or, even better, fork the repository on GitHub and create a pull request (PR). We welcome all changes, big or small, and we will help you make the PR if you are new to git.

License

Released under Creative Commons by-nc-sa 4.0 (see LICENSE):

Copyright (C) 2023-2024 NetIn Developers
Fariba Karimi <[email protected]>
Lisette Espin-Noboa <[email protected]>
Jan Bachmann <[email protected]>

networkinequalities's People

Contributors

lisette-espin avatar mannbach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

sudhang

networkinequalities's Issues

Implement graph-tool

We should provide an alternative to NetworkX to improve performance.

Some requirements from the top of my head:

  1. Using graph-tool should be optional. Only when people specifically select it, we should require it to be installed.
  2. It should be hidden behind an abstract network layer (which needs to be implemented for this purpose). This abstract layer describes the network and the functions we need (e.g., for adding nodes, labels and analyses). From the abstract network layer, inheriting classes can implement the access to NetworkX and graph-tool objects respectively.

Biased selection of triadic_closure_candidates

Right now, the selection of targets from the set of triadic_closure_candidates is biased towards those with more connections in common (i.e., weighted by friends-in-commom).

We need an alternative version where nodes are selected uniformly at random by adding a flag in the constructor of netin.TriadicClosure

Types of undirected edges

The method netin.stats.networks.get_edge_type_counts should merge the counts for Mm and mM when the network is undirected.

Plotting types of edges

Add a method to plot edge counts in netin.viz.handlers, and include parameter to plot fraction of edges too.

  • Overall fraction across all edges in the network
  • Fraction within group: (mm and mM), and (MM and Mm)

Implement binary tree sampling method for preferential attachment

Use a binary tree data structure to store (unnormalized) probabilities for picking nodes with preferential attachment. This avoids computing the whole array of probabilities with each new node.

Instead, one can traverse a binary tree in which the leaves are target nodes. Their parent nodes are defined by the cumulative sum of their two children. One can then flip O(log N) coins (with N existing nodes) in each round to randomly traverse to the bottom and hence find a target to connect to. At each level, the coin is weighted by the cumulative sum of the two children. The tree can be extended by updating only the path to the newly added leave node.

Order in target selection is not deterministic

In the network generation process, when a new node wants to link to an existing once, we collect potential target candidates together with the probability to connect to them.
See, for instance, pah.get_target_probabilities.
The return type is a list of probabilities and a set of target nodes.

The order over which a set iterated, is not defined and can vary from run to run, even when the set content is identical.
We cannot be sure that the first probability in the list belongs to the nodes which appeared first in an iteration over the corresponding set.
This can lead to assigning the wrong connection probability to nodes in random ways.

We should either

  • unify both in a dictionary or
  • additionally return an ordered list of candidate nodes or
  • remove the target set (typically, only the probabilities are extracted)

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.