Skip to main content

Python Random Graph Generator

Project description

PyRGG: Python Random Graph Generator

PyPI version Codecov built with Python3 Discord Channel

Overview

PyRGG is a user-friendly synthetic random graph generator that is written in Python and supports multiple graph file formats, such as DIMACS-Graph files. It can generate graphs of various sizes and is specifically designed to create input files for a wide range of graph-based research applications, including testing, benchmarking, and performance analysis of graph processing frameworks. PyRGG is aimed at computer scientists who are studying graph algorithms and graph processing frameworks.

Open Hub
PyPI Counter PyPI Downloads
Github Stars
Branch master dev
CI
Code Quality codebeat badge CodeFactor

Installation

PyPI

Source Code

Conda

Exe Version

⚠️ Only Windows

⚠️ For PyRGG targeting Windows < 10, the user needs to take special care to include the Visual C++ run-time .dlls(for more information visit here)

System Requirements

PyRGG will likely run on a modern dual core PC. Typical configuration is:

  • Dual Core CPU (2.0 Ghz+)
  • 4GB of RAM

⚠️ Note that it may run on lower end equipment though good performance is not guaranteed

Usage

  • Open CMD (Windows) or Terminal (Linux)
  • Run pyrgg or python -m pyrgg (or run PYRGG.exe)
  • Enter data

Engines

PyRGG

Parameter Description
Vertices Number The total number of vertices in the graph
Min Edge Number The minimum number of edges connected to each vertex
Max Edge Number The maximum number of edges connected to each vertex
Weighted / Unweighted Specifies whether the graph is weighted or unweighted
Min Weight The minimum weight of the edges (if weighted)
Max Weight The maximum weight of the edges (if weighted)
Signed / Unsigned Specifies whether the edge weights are signed or unsigned
Directed / Undirected Specifies whether the graph is directed or undirected
Self Loop / No Self Loop Specifies whether self-loop is allowed or not
Simple / Multigraph Specifies whether the graph is a simple graph or a multigraph

Erdős–Rényi-Gilbert

Parameter Description
Vertices Number The total number of vertices in the graph
Probability The probability for edge creation between any two vertices
Directed / Undirected Specifies whether the graph is directed or undirected

Erdős–Rényi

Parameter Description
Vertices Number The total number of vertices in the graph
Edge Number The total number of edges in the graph
Directed / Undirected Specifies whether the graph is directed or undirected

Supported Formats

DIMACS

	p sp <number of vertices> <number of edges>
	a <head_1> <tail_1> <weight_1>

	.
	.
	.
		
	a <head_n> <tail_n> <weight_n>

CSV

	<head_1>,<tail_1>,<weight_1>

	.
	.
	.
		
	<head_n>,<tail_n>,<weight_n>

TSV

	<head_1>	<tail_1>	<weight_1>

	.
	.
	.
		
	<head_n>	<tail_n>	<weight_n>

JSON

{
	"properties": {
		"directed": true,
		"signed": true,
		"multigraph": true,
		"weighted": true,
		"self_loop": true
	},
	"graph": {
		"nodes":[
		{
			"id": 1
		},

		.
		.
		.

		{
			"id": n
		}
		],
		"edges":[
		{
			"source": head_1,
			"target": tail_1,
			"weight": weight_1
		},

		.
		.
		.

		{
			"source": head_n,
			"target": tail_n,
			"weight": weight_n
		}
		]
	}
}

YAML

 	graph:
 		edges:
 		- source: head_1
 	  	target: tail_1
 	  	weight: weight_1
 	
 		.
 		.
 		.

 		- source: head_n
 	  	target: tail_n
 	  	weight: weight_n
 					
 		nodes:
 		- id: 1

 		.
 		.
 		.

 		- id: n
 	properties:
 		directed: true
 		multigraph: true
 		self_loop: true
 		signed: true
 		weighted: true

Weighted Edge List

	<head_1> <tail_1> <weight_1>
		
	.
	.
	.
		
	<head_n> <tail_n> <weight_n>	

ASP

	node(1).
	.
	.
	.
	node(n).
	edge(head_1,tail_1,weight_1).
	.
	.
	.
	edge(head_n,tail_n,weight_n).

Trivial Graph Format

	1
	.
	.
	.
	n
	#
	1 2 weight_1
	.
	.
	.
	n k weight_n

UCINET DL Format

	dl
	format=edgelist1
	n=<number of vertices>
	data:
	1 2 weight_1
	.
	.
	.
	n k weight_n	

Matrix Market

    %%MatrixMarket matrix coordinate real general
    <number of vertices>  <number of vertices>  <number of edges>
    <head_1>    <tail_1>    <weight_1> 
    .
    .
    .
    <head_n>    <tail_n>    <weight_n> 

Graph Line

	<head_1> <tail_1>:<weight_1> <tail_2>:<weight_2>  ... <tail_n>:<weight_n>
	<head_2> <tail_1>:<weight_1> <tail_2>:<weight_2>  ... <tail_n>:<weight_n>
	.
	.
	.
	<head_n> <tail_1>:<weight_1> <tail_2>:<weight_2>  ... <tail_n>:<weight_n>

GDF

    nodedef>name VARCHAR,label VARCHAR
    node_1,node_1_label
    node_2,node_2_label
    .
    .
    .
    node_n,node_n_label
    edgedef>node1 VARCHAR,node2 VARCHAR, weight DOUBLE
    node_1,node_2,weight_1
    node_1,node_3,weight_2
    .
    .
    .
    node_n,node_2,weight_n 

GML

    graph
    [
      multigraph 0
      directed  0
      node
      [
       id 1
       label "Node 1"
      ]
      node
      [
       id 2
       label "Node 2"
      ]
      .
      .
      .
      node
      [
       id n
       label "Node n"
      ]
      edge
      [
       source 1
       target 2
       value W1
      ]
      edge
      [
       source 2
       target 4
       value W2
      ]
      .
      .
      .
      edge
      [
       source n
       target r
       value Wn
      ]
    ]

GEXF

     <?xml version="1.0" encoding="UTF-8"?>
     <gexf xmlns="http://www.gexf.net/1.2draft" version="1.2">
         <meta lastmodifieddate="2009-03-20">
             <creator>PyRGG</creator>
             <description>File Name</description>
         </meta>
         <graph defaultedgetype="directed">
             <nodes>
                 <node id="1" label="Node 1" />
                 <node id="2" label="Node 2" />
                 ...
             </nodes>
             <edges>
                 <edge id="1" source="1" target="2" weight="400" />
                 ...
             </edges>
         </graph>
     </gexf>

Graphviz

	graph example 
		{
		node1 -- node2 [weight=W1];
		node3 -- node4 [weight=W2];
		node1 -- node3 [weight=W3];
		.
		.
		.
		}

Pickle

⚠️ Binary format

Issues & Bug Reports

Just fill an issue and describe it. We'll check it ASAP! or send an email to info@pyrgg.site.

You can also join our discord server

Discord Channel

Citing

If you use PyRGG in your research, please cite the JOSS paper ;-)

@article{Haghighi2017,
  doi = {10.21105/joss.00331},
  url = {https://doi.org/10.21105/joss.00331},
  year  = {2017},
  month = {sep},
  publisher = {The Open Journal},
  volume = {2},
  number = {17},
  author = {Sepand Haghighi},
  title = {Pyrgg: Python Random Graph Generator},
  journal = {The Journal of Open Source Software}
}
JOSS
Zenodo DOI

References

1- 9th DIMACS Implementation Challenge - Shortest Paths
2- Problem Based Benchmark Suite
3- MaximalClique - ASP Competition 2013
4- Pitas, Ioannis, ed. Graph-based social media analysis. Vol. 39. CRC Press, 2016.
5- Roughan, Matthew, and Jonathan Tuke. "The hitchhikers guide to sharing graph data." 2015 3rd International Conference on Future Internet of Things and Cloud. IEEE, 2015.
6- Borgatti, Stephen P., Martin G. Everett, and Linton C. Freeman. "Ucinet for Windows: Software for social network analysis." Harvard, MA: analytic technologies 6 (2002).
7- Matrix Market: File Formats
8- Social Network Visualizer
9- Adar, Eytan. "GUESS: a language and interface for graph exploration." Proceedings of the SIGCHI conference on Human Factors in computing systems. 2006.
10- Skiena, Steven S. The algorithm design manual. Springer International Publishing, 2020.
11- Chakrabarti, Deepayan, Yiping Zhan, and Christos Faloutsos. "R-MAT: A recursive model for graph mining." Proceedings of the 2004 SIAM International Conference on Data Mining. Society for Industrial and Applied Mathematics, 2004.
12- Zhong, Jianlong, and Bingsheng He. "An overview of medusa: simplified graph processing on gpus." ACM SIGPLAN Notices 47.8 (2012): 283-284.
13- Ellson, John, et al. "Graphviz and dynagraph—static and dynamic graph drawing tools." Graph drawing software. Springer, Berlin, Heidelberg, 2004. 127-148.
14- Gilbert, Edgar N. "Random graphs." The Annals of Mathematical Statistics 30.4 (1959): 1141-1144.
15- Erdős, Paul, and Alfréd Rényi. "On the strength of connectedness of a random graph." Acta Mathematica Hungarica 12.1 (1961): 261-267.

Show Your Support

Star This Repo

Give a ⭐️ if this project helped you!

Donate to Our Project

If you do like our project and we hope that you do, can you please support us? Our project is not and is never going to be working for profit. We need the money just so we can continue doing what we do ;-) .

PyRGG Donation

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Unreleased

1.6 - 2024-11-13

Added

  • pyrgg.engines.erdos_reyni module
  • save_log function

Changed

  • PyPI badge in README.md updated
  • logger function format for erdos_reyni_gilbert changed
  • GitHub actions are limited to the dev and master branches
  • README.md modified
  • build_exe.bat modified
  • Python 3.13 added to test.yml

1.5 - 2024-09-16

Added

  • feature_request.yml template
  • config.yml for issue template
  • pyrgg.engines package
  • pyrgg.engines.pyrgg module
  • pyrgg.engines.erdos_reyni_gilbert module
  • Erdős-Rényi-Gilbert generation model
  • Generation engine menu
  • handle_string function
  • handle_pos_int function
  • handle_output_format function
  • handle_engine function
  • SECURITY.md

Changed

  • Metadata in files modified
  • Python 3.5 support dropped
  • Bug report template modified
  • Cprofile tests separated in files for engines
  • README.md modified
  • Python 3.12 added to test.yml
  • Menu options bug fixed
  • Test system modified
  • engine parameter added to logger function
  • MENU_ITEMS1 parameter changed to MENU_ITEMS
  • MENU_ITEMS2 parameter changed to PYRGG_ENGINE_PARAMS
  • _update_using_first_menu function changed to _update_using_menu
  • _update_using_second_menu function changed to _update_with_engine_params
  • ITEM_CONVERTORS renamed to ITEM_HANDLERS
  • Website domain changed to https://www.pyrgg.site

Removed

  • dimacs_init function

1.4 - 2023-07-06

Added

  • check_for_config function
  • load_config function
  • save_config function

Changed

  • README.md modified
  • Logo changed
  • codecov removed from dev-requirements.txt
  • Test system modified
  • Error messages updated

1.3 - 2022-11-30

Added

  • Graphviz(DOT) format

Changed

  • asciinema instruction video updated
  • Test system modified
  • README.md modified
  • Python 3.11 added to test.yml
  • CLI mode updated
  • dev-requirements.txt updated
  • To-do list moved to TODO.md

1.2 - 2022-09-07

Added

  • Anaconda workflow
  • Discord badge

Changed

  • Menu optimized
  • Docstrings modified
  • branch_gen function modified
  • edge_gen function modified
  • precision and min_edge parameters added to branch_gen function
  • random_edge parameter removed from branch_gen function
  • Test system modified
  • AUTHORS.md updated
  • License updated
  • README.md modified
  • Python 3.10 added to test.yml

Removed

  • sign_gen function
  • random_edge_limits function

1.1 - 2021-06-09

Added

  • requirements-splitter.py
  • is_weighted function
  • _write_properties_to_json function
  • PYRGG_TEST_MODE parameter

Changed

  • Test system modified
  • JSON, YAML and Pickle formats value changed from string to number
  • properties section added to JSON, YAML and Pickle formats
  • _write_to_json function renamed to _write_data_to_json
  • logger function modified
  • time_convert function modified
  • branch_gen function modified
  • References updated

1.0 - 2021-01-11

Added

  • Number of files option

Changed

  • All flags type changed to bool
  • Menu optimized
  • The logger function enhanced.
  • Time format in the logger changed to %Y-%m-%d %H:%M:%S
  • dl_maker function modified
  • tgf_maker function modified
  • gdf_maker function modified
  • run function modified

0.9 - 2020-10-07

Added

  • GEXF format
  • Float weight support
  • tox.ini

Changed

  • Menu optimized
  • pyrgg.py renamed to graph_gen.py
  • Other functions moved to functions.py
  • Test system modified
  • params.py refactored
  • graph_gen.py refactored
  • functions.py refactored
  • weight_str_to_number function renamed to convert_str_to_number
  • branch_gen function bugs fixed
  • input_filter function bug fixed
  • gl_maker function bug fixed
  • CONTRIBUTING.md updated
  • AUTHORS.md updated

Removed

  • print_test function
  • left_justify function
  • justify function
  • zero_insert function

0.8 - 2020-08-19

Added

  • GDF format
  • GML format

Changed

  • CLI snapshots updated
  • AUTHORS.md updated

0.7 - 2020-08-07

Added

  • Graph Line format

Changed

  • Menu optimized

0.6 - 2020-07-24

Added

  • Matrix Market format

Changed

  • json_maker function optimized
  • dl_maker function optimized
  • tgf_maker function optimized
  • lp_maker function optimized

0.5 - 2020-07-01

Added

  • TSV format
  • Multigraph control

Changed

0.4 - 2020-06-17

Added

  • Self loop control
  • Github action

Changed

  • appveyor.yml updated

0.3 - 2019-11-29

Added

  • __version__ variable
  • CHANGELOG.md
  • dev-requirements.txt
  • requirements.txt
  • CODE_OF_CONDUCT.md
  • ISSUE_TEMPLATE.md
  • PULL_REQUEST_TEMPLATE.md
  • CONTRIBUTING.md
  • version_check.py
  • pyrgg_profile.py
  • Unweighted graph
  • Undirected graph
  • Exe version

Changed

  • Test system modified
  • README.md modified
  • Docstrings modified
  • get_input function modified
  • edge_gen function modified
  • Parameters moved to params.py

0.2 - 2017-09-20

Added

  • CSV format
  • YAML format
  • Weighted edge list format (WEL)
  • ASP format
  • Trivial graph format (TGF)
  • UCINET DL format
  • Pickle format

0.1 - 2017-08-19

Added

  • DIMACS format
  • JSON format
  • README

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

pyrgg-1.6.tar.gz (240.1 kB view details)

Uploaded Source

Built Distribution

pyrgg-1.6-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

Details for the file pyrgg-1.6.tar.gz.

File metadata

  • Download URL: pyrgg-1.6.tar.gz
  • Upload date:
  • Size: 240.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pyrgg-1.6.tar.gz
Algorithm Hash digest
SHA256 bbeeea7655d791c935d86f53c63b82431e1e034900d984347006a96165869201
MD5 2703cd7576703d38a27675c820fb3a95
BLAKE2b-256 f96927646373ea6ce33ce9edc8b6aa8962e625e36dc545308490d580ee85f1c9

See more details on using hashes here.

File details

Details for the file pyrgg-1.6-py3-none-any.whl.

File metadata

  • Download URL: pyrgg-1.6-py3-none-any.whl
  • Upload date:
  • Size: 32.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pyrgg-1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 8248599150ad9f6f527d1bbe295d169f541d80c6793426e208d1a611f8b734cc
MD5 f8a19d825ad7258f3bf3e0c39f555329
BLAKE2b-256 136b7743f9f7f6f83bb25e8243b0964dc2970c1a771bf22e1dce40dffb72ad96

See more details on using hashes here.

Supported by

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