GithubHelp home page GithubHelp logo

graph_generator's Introduction

graph_generator

A simple graph generator in Python.

help

user> ./graph_generator.py -h
usage: graph_generator.py [-h] [-v VERTICES] [-d DENSITY] [-md MAX_D]
                          [-s SEED] [-dir] [-l]

Generate a random undirected graph

optional arguments:
  -h, --help            show this help message and exit
  -v VERTICES, --vertices VERTICES
                        the number of vertices, default: 5
  -d DENSITY, --density DENSITY
                        probability of an edge to be created, default 0.4
  -md MAX_D, --max_d MAX_D
                        max distance of an edge, default: 10.0
  -s SEED, --seed SEED  seed string, input to random.seed funtion, default:
                        datetime.now() value
  -dir, --directed      assume directed graph, default is undirected
  -l, --loop            permit loops, default loops are not permitted

usage

number of vertices

Create a graph with 5 vertices and probability 1 that any edge exists. Default density probability is 0.40.

user> ./graph_generator.py -v 5 -d 1
   0    1   8.241189
   0    2   4.117791
   0    3   6.369332
   0    4   2.315471
   1    2   2.389442
   1    3   3.020105
   1    4   7.396298
   2    3   8.626766
   2    4   0.984170
   3    4   7.679901

Create a graph with 10 vertices and probability 0.40 that any edge exists.

user> ./graph_generator.py -v 10
   0    4   1.856113
   0    5   9.167582
   0    7   4.295258
   1    4   1.199899
   1    6   0.371146
   1    9   4.633235
   2    4   8.496948
   2    6   9.353413
   2    9   2.615050
   3    5   3.202757
   3    6   1.779892
   3    8   0.043698
   5    7   2.369914
   6    8   8.740469
   7    9   0.864979

max distance

Create a graph with 4 vertices and probability 1 that any edge exists, with each edge length between 0.0 and 24.0.

user> ./graph_generator.py -v 4 -d 1 -md 24.0
   0    1   9.036901
   0    2  19.743478
   0    3  20.234961
   1    2  23.784967
   1    3  13.496640
   2    3   8.423459

directed graph

Create a directed graph with 4 vertices and probability 1 that any edge exists, with each edge length between 0.0 and 5.0.

user> ./graph_generator.py -v 4 -d 1 -md 5.0 -dir
   0    1   3.404863
   0    2   3.213175
   0    3   3.053851
   1    0   4.751465
   1    2   0.518659
   1    3   3.239149
   2    0   2.242328
   2    1   1.474554
   2    3   2.505322
   3    0   0.347947
   3    1   2.859499
   3    2   3.876708

loops (edge from vertex to itself is permitted)

Create a directed graph with 3 vertices and probability 1 that any edge exists, with each edge length between 0.0 and 10.0, where loops are permitted.

user> ./graph_generator.py -v 3 -d 1 -md 10.0 -dir -l
   0    0   7.545652
   0    1   2.331990
   0    2   6.899898
   1    0   8.483664
   1    1   3.025699
   1    2   6.373641
   2    0   1.872887
   2    1   4.078114
   2    2   1.067111

using the same seed gives the same results

Create an undirected graph with 5 vertices and probability 0.40 that any edge exists, with each edge length between 0.0 and 10.0, using random_text as seed.

user> ./graph_generator.py -s random_text
   0    3   7.047966
   1    3   4.807293
   3    4   6.304101
user> ./graph_generator.py -s random_text
   0    3   7.047966
   1    3   4.807293
   3    4   6.304101

graph_generator's People

Contributors

sotirop avatar

Watchers

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