Python Random Graph Generator
Project description
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 | |
| Github Stars |
| Branch | master | dev |
| CI |
| Code Quality |
Installation
PyPI
- Check Python Packaging User Guide
pip install pyrgg==1.9
Source Code
- Download Version 1.9 or Latest Source
pip install .
Conda
- Check Conda Managing Package
conda install -c sepandhaghighi pyrgg
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)
- Download Exe-Version 1.9
- Run
PYRGG-1.9.exe
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) orTerminal(Linux) - Run
pyrggorpython -m pyrgg(or runPYRGG.exe) - Enter data
Engines
PyRGG
| Parameter | Description |
|---|---|
| Vertices Number (n) | 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 (n) | The total number of vertices in the graph |
| Probability (p) | The probability for an edge creation between any two vertices |
| Directed / Undirected | Specifies whether the graph is directed or undirected |
Erdős–Rényi
| Parameter | Description |
|---|---|
| Vertices Number (n) | The total number of vertices in the graph |
| Edge Number (m) | The total number of edges in the graph |
| Directed / Undirected | Specifies whether the graph is directed or undirected |
Stochastic Block Model
| Parameter | Description |
|---|---|
| Vertices Number (n) | The total number of vertices in the graph |
| Block Number (k) | The number of blocks (disjoint subsets) |
| Block Sizes ([|C1|, |C2|, ... |Ck|]) | List of block sizes. The should sum up to n (n = |C1|+|C2|+...+|Ck|). |
| Probability Matrix ([[P11, P12, ..., P1k], ... [Pk1, Pk2, ..., Pkk]]) | Edge probabilities for between and within block connections. For undirected graph only the upper triangular indices would be counted. |
| Directed / Undirected | Specifies whether the graph is directed or undirected |
| Self Loop / No Self Loop | Specifies whether self-loop is allowed or not |
Barabási-Albert
| Parameter | Description |
|---|---|
| Vertices Number (n) | The total number of vertices in the graph |
| Attaching Edge Number (k) | The number of edges to attach to a new node |
Watts-Strogatz
| Parameter | Description |
|---|---|
| Vertices Number (n) | The total number of vertices in the graph |
| Mean Degree (k) | The number of connections in the initial lattice (should be a positive even number) |
| Rewiring Probability (p) | The probability by which each node would be rewired to another node |
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>
- Document
- Sample 1 (100 Vertices , 3KB)
- Sample 2 (1000 Vertices , 13KB)
- Sample 3 (1000000 Vertices , 7MB)
- Sample 4 (5000000 Vertices , 37MB)
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];
.
.
.
}
- Document
- Sample 1 (100 Vertices , 11KB)
- Sample 2 (1000 Vertices , 106KB)
- Online Visualization
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
Cite
If you use PyRGG in your research, we would appreciate citations to the following 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 |
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.
16- Barabási, Albert-László, and Réka Albert. "Emergence of scaling in random networks." science 286.5439 (1999): 509-512.
17- Watts, Duncan J., and Steven H. Strogatz. "Collective dynamics of ‘small-world’networks." nature 393.6684 (1998): 440-442.
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 ;-) .
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.9 - 2025-10-28
Added
pyrgg.engines.watts_strogatzmodule
Changed
threshold_calcfunction renamed tocalculate_thresholddescription_printfunction renamed toprint_descriptionlinefunction renamed toprint_lineinput_filterfunction renamed tofilter_inputfilesizefunction renamed toget_file_sizetime_convertfunction renamed toconvert_time- String templates modified
- Test system modified
Python 3.14added totest.ymlREADME.mdmodified
1.8 - 2025-08-26
Added
pyrgg.engines.barabasi_albertmodule
Changed
- CLI messages for stochastic block model updated
README.mdmodifiedmin_edgerenamed tomin_edgesmax_edgerenamed tomax_edgesweight_dicrenamed toweight_dictedge_dicrenamed toedge_dict
Removed
handle_prob_matrixfunctionhandle_pos_listfunction
1.7 - 2025-05-15
Added
pyrgg.engines.stochastic_block_modelmodule
Changed
Python 3.6support dropped- Test system modified
1.6 - 2024-11-13
Added
pyrgg.engines.erdos_reynimodulesave_logfunction
Changed
- PyPI badge in
README.mdupdated loggerfunction format forerdos_reyni_gilbertchanged- GitHub actions are limited to the
devandmasterbranches README.mdmodifiedbuild_exe.batmodifiedPython 3.13added totest.yml
1.5 - 2024-09-16
Added
feature_request.ymltemplateconfig.ymlfor issue templatepyrgg.enginespackagepyrgg.engines.pyrggmodulepyrgg.engines.erdos_reyni_gilbertmoduleErdős-Rényi-Gilbertgeneration model- Generation engine menu
handle_stringfunctionhandle_pos_intfunctionhandle_output_formatfunctionhandle_enginefunctionSECURITY.md
Changed
- Metadata in files modified
Python 3.5support dropped- Bug report template modified
- Cprofile tests separated in files for engines
README.mdmodifiedPython 3.12added totest.yml- Menu options bug fixed
- Test system modified
engineparameter added tologgerfunctionMENU_ITEMS1parameter changed toMENU_ITEMSMENU_ITEMS2parameter changed toPYRGG_ENGINE_PARAMS_update_using_first_menufunction changed to_update_using_menu_update_using_second_menufunction changed to_update_with_engine_paramsITEM_CONVERTORSrenamed toITEM_HANDLERS- Website domain changed to https://www.pyrgg.site
Removed
dimacs_initfunction
1.4 - 2023-07-06
Added
check_for_configfunctionload_configfunctionsave_configfunction
Changed
README.mdmodified- Logo changed
codecovremoved fromdev-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.mdmodifiedPython 3.11added totest.yml- CLI mode updated
dev-requirements.txtupdated- To-do list moved to
TODO.md
1.2 - 2022-09-07
Added
- Anaconda workflow
- Discord badge
Changed
- Menu optimized
- Docstrings modified
branch_genfunction modifiededge_genfunction modifiedprecisionandmin_edgeparameters added tobranch_genfunctionrandom_edgeparameter removed frombranch_genfunction- Test system modified
AUTHORS.mdupdated- License updated
README.mdmodifiedPython 3.10added totest.yml
Removed
sign_genfunctionrandom_edge_limitsfunction
1.1 - 2021-06-09
Added
requirements-splitter.pyis_weightedfunction_write_properties_to_jsonfunctionPYRGG_TEST_MODEparameter
Changed
- Test system modified
- JSON, YAML and Pickle formats value changed from
stringtonumber propertiessection added to JSON, YAML and Pickle formats_write_to_jsonfunction renamed to_write_data_to_jsonloggerfunction modifiedtime_convertfunction modifiedbranch_genfunction modified- References updated
1.0 - 2021-01-11
Added
- Number of files option
Changed
- All flags type changed to
bool - Menu optimized
- The
loggerfunction enhanced. - Time format in the
loggerchanged to%Y-%m-%d %H:%M:%S dl_makerfunction modifiedtgf_makerfunction modifiedgdf_makerfunction modifiedrunfunction modified
0.9 - 2020-10-07
Added
- GEXF format
- Float weight support
tox.ini
Changed
- Menu optimized
pyrgg.pyrenamed tograph_gen.py- Other functions moved to
functions.py - Test system modified
params.pyrefactoredgraph_gen.pyrefactoredfunctions.pyrefactoredweight_str_to_numberfunction renamed toconvert_str_to_numberbranch_genfunction bugs fixedinput_filterfunction bug fixedgl_makerfunction bug fixedCONTRIBUTING.mdupdatedAUTHORS.mdupdated
Removed
print_testfunctionleft_justifyfunctionjustifyfunctionzero_insertfunction
0.8 - 2020-08-19
Added
- GDF format
- GML format
Changed
- CLI snapshots updated
AUTHORS.mdupdated
0.7 - 2020-08-07
Added
- Graph Line format
Changed
- Menu optimized
0.6 - 2020-07-24
Added
- Matrix Market format
Changed
json_makerfunction optimizeddl_makerfunction optimizedtgf_makerfunction optimizedlp_makerfunction optimized
0.5 - 2020-07-01
Added
- TSV format
- Multigraph control
Changed
branch_genfunction modified- Website changed to https://www.pyrgg.ir
0.4 - 2020-06-17
Added
- Self loop control
- Github action
Changed
appveyor.ymlupdated
0.3 - 2019-11-29
Added
__version__variableCHANGELOG.mddev-requirements.txtrequirements.txtCODE_OF_CONDUCT.mdISSUE_TEMPLATE.mdPULL_REQUEST_TEMPLATE.mdCONTRIBUTING.mdversion_check.pypyrgg_profile.py- Unweighted graph
- Undirected graph
- Exe version
Changed
- Test system modified
README.mdmodified- Docstrings modified
get_inputfunction modifiededge_genfunction 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyrgg-1.9.tar.gz.
File metadata
- Download URL: pyrgg-1.9.tar.gz
- Upload date:
- Size: 250.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c945c872c49d59a4e5f091c3ccd90762d06997c603cf1f0cf6bbb1d611654e3e
|
|
| MD5 |
4d85ac1ffda23e2ac4c763489e290987
|
|
| BLAKE2b-256 |
3594aa6bf0ae7af486822cb3eb498d8c30e62ae2e20646972edd3a2aafe0d499
|
File details
Details for the file pyrgg-1.9-py3-none-any.whl.
File metadata
- Download URL: pyrgg-1.9-py3-none-any.whl
- Upload date:
- Size: 38.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8db42b266d93c0be5f0184478150cb1deb7bea575b538078651a8695b2ce39a
|
|
| MD5 |
3bb88c8c8bb6d3e0bc20e2b09f89d54c
|
|
| BLAKE2b-256 |
51a94e1842e6000821765753f00311d3797bffddee68fef60132916fd823a160
|