Skip to main content

drawing uniformly graphs under constraint. Commonly used for the estimation of the test distribution

Project description

Unifor Graph Draw

currently in production

This package implements random draw algorithm for networks. In particular it creates uniform samples of networks with a given degreesequence and further constraints (fixed number of crossing edges/arrows between node-groups)

It is implement according to the papers:

  • ...
  • ...

The papers also include a proof of correctness and a discussion of the statistical background.

Get it running

Install the paper via pip:

  • pip install ugd

then run

import ugd
import numpy
adj_m = numpy.zeros((4,4))
adj_m[0,1] = 1
adj_m[1,0] = 1
adj_m[3,2] = 1
adj_m[2,3] = 1
var_dict ={
    0: {'gender': 'm'},
    1: {'gender': 'm'},
    2: {'gender': 'f'},
    3: {'gender': 'f'},
}
graphs, stats_list = graph_hyp_test(adj_m=adj_m, var_dict = var_dict, test_variable= ('gender','m','f'),mixing_time=10000, anz_sim=100, show_polt=True)

For an illustration more extensive use cases, see the examples scripts in:

API

There are two functions provided.

  • digraph_hyp_test
    • generating a sequence of uniform sapled digraphs under the desired set of constrains.
  • graph_hyp_test
    • generating a sequence of uniform sapled digraphs under the desired set of constrains.

For a exact API documentation as well as a usage examples see the function documentation.

Comment:

The current implementation, includes only controlling of a fixed number of crossing edges/arrows between node-groups as constraints. More complex complex can be implemented by writing a consum implementation of the no_violation function in constraint_violation_check. Note, that depending on the constraint the construction of the Schlaufensequence should not be stopped because a feasible one is found, but only due to the random stop. This in order to preserve correctness.

Architecture:

All the logic is implemented in the digraph_draw folder. it is divided into

  • model

    • containing the data models (appropriate Graph representation and node representation for efficient construction of the altering paths in the Schlaufen)
  • high_level_intervace

    Contains the all the logic used for input validation, parsing of input, estimation of runtime, transformation of the graph format, output processing.

  • help_functions

The actual logic for sampling the graphs is in:

  • markow_walk * Implementation of algoritm "" from the paper ....

  • schlaufen_construction * Implementation of algoritm "" from the paper ....

Testing

based on pytest. cd into mcd directory and run

  • pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ugd-0.0.2.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ugd-0.0.2-py3-none-any.whl (55.5 kB view details)

Uploaded Python 3

File details

Details for the file ugd-0.0.2.tar.gz.

File metadata

  • Download URL: ugd-0.0.2.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.5.2

File hashes

Hashes for ugd-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ed4e73c13157182ff880d0acb240eeae73c51b4ea19a2c7a00e90ae46946ed3c
MD5 771e76069c3571036294f0f9533f1bb0
BLAKE2b-256 1b0ae5e9d204d34e2b0216ea41fcca9032d0b88a5d3cdb53edd24bbdf0806baa

See more details on using hashes here.

File details

Details for the file ugd-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: ugd-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 55.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.5.2

File hashes

Hashes for ugd-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 40fdf3095b04dd98f6ea866a9fadf2d011b151dd3299ad0731d28bdb4f014bd3
MD5 3e2191fea051485f472dd1aece0f4cdb
BLAKE2b-256 6629c29d3429bec4348115c39b32761b9607e1e7e7fd44a59067227ee2f55a7b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page