Code Monkey home page Code Monkey logo

pyrgg's Introduction

PyRGG: Python Random Graph Generator

PyPI version Codecov built with Python3 Discord Channel

Table of Contents

Overview

Pyrgg is an easy-to-use synthetic random graph generator written in Python which supports various graph file formats including DIMACS .gr files. Pyrgg has the ability to generate graphs of different sizes and is designed to provide input files for broad range of graph-based research applications, including but not limited to testing, benchmarking and performance-analysis of graph processing frameworks. Pyrgg target audiences are computer scientists who study graph algorithms and graph processing frameworks.

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

Installation

PyPI

Source Code

Conda

Exe Version (Only Windows)

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 (UNIX)
  • Run pyrgg or python -m pyrgg (or run PYRGG.exe)
  • Enter data

Supported Formats

  • DIMACS(.gr)

     	p sp <number of vertices> <number of edges>
     	a <head_1> <tail_1> <weight_1>
    
     	.
     	.
     	.
     	
     	a <head_n> <tail_n> <weight_n>
    
  • CSV(.csv)

     	<head_1>,<tail_1>,<weight_1>
    
     	.
     	.
     	.
     	
     	<head_n>,<tail_n>,<weight_n>
    
  • TSV(.tsv)

     	<head_1>	<tail_1>	<weight_1>
    
     	.
     	.
     	.
     	
     	<head_n>	<tail_n>	<weight_n>
    
  • JSON(.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(.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(.wel)

     	<head_1> <tail_1> <weight_1>
     	
     	.
     	.
     	.
     	
     	<head_n> <tail_n> <weight_n>	
    
  • ASP(.lp)

     	node(1).
     	.
     	.
     	.
     	node(n).
     	edge(head_1,tail_1,weight_1).
     	.
     	.
     	.
     	edge(head_n,tail_n,weight_n).
    
  • Trivial Graph Format(.tgf)

     	1
     	.
     	.
     	.
     	n
     	#
     	1 2 weight_1
     	.
     	.
     	.
     	n k weight_n
    
  • UCINET DL Format(.dl)

     	dl
     	format=edgelist1
     	n=<number of vertices>
     	data:
     	1 2 weight_1
     	.
     	.
     	.
     	n k weight_n	
    
  • Matrix Market(.mtx)

        %%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(.gl)

        <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(.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(.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(.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(.gv)

    	graph example 
    		{
    		node1 -- node2 [weight=W1];
    		node3 -- node4 [weight=W2];
    		node1 -- node3 [weight=W3];
    		.
    		.
    		.
    		}
    
  • Pickle(.p) (Binary Format)

Example of Usage

  • Generate synthetic data for graph processing frameworks (some of them mentioned here) performance-analysis
  • Generate synthetic data for graph benchmark suite like GAP

Similar Works

Issues & Bug Reports

Just fill an issue and describe it. We'll check it ASAP! or send an email to [email protected].

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.

Show Your Support

Star This Repo

Give a ⭐️ if this project helped you!

Donate to Our Project

Bitcoin

1KtNLEEeUbTEK9PdN6Ya3ZAKXaqoKUuxCy

Ethereum

0xcD4Db18B6664A9662123D4307B074aE968535388

Litecoin

Ldnz5gMcEeV8BAdsyf8FstWDC6uyYR6pgZ

Doge

DDUnKpFQbBqLpFVZ9DfuVysBdr249HxVDh

Tron

TCZxzPZLcJHr2qR3uPUB1tXB6L3FDSSAx7

Ripple

rN7ZuRG7HDGHR5nof8nu5LrsbmSB61V1qq

Binance Coin

bnb1zglwcf0ac3d0s2f6ck5kgwvcru4tlctt4p5qef

Tether

0xcD4Db18B6664A9662123D4307B074aE968535388

Dash

Xd3Yn2qZJ7VE8nbKw2fS98aLxR5M6WUU3s

Stellar

GALPOLPISRHIYHLQER2TLJRGUSZH52RYDK6C3HIU4PSMNAV65Q36EGNL

Zilliqa

zil1knmz8zj88cf0exr2ry7nav9elehxfcgqu3c5e5

Coffeete

pyrgg's People

Contributors

ahmadsalimi avatar codacy-badger avatar dependabot-preview[bot] avatar dependabot[bot] avatar ivanovmg avatar sadrasabouri avatar sepandhaghighi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pyrgg's Issues

Convert the JSON nodes to integers from objects

Description

Currently the nodes array in the JSON file is full of objects for each nodes - each containing only the id field.
I think that it would be much better to just get rid of those objects and replace them all with the IDs themselves.

New graph format

Description

Graph-Line format

0 1:4 2:4 3:1 4:4 5:4 6:2 7:1 8:1 9:4

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

Extract the functional part

Description

I think pyrgg is now an executable script that takes the graph specifications and outputs a file containing a random graph.
What if someone wants to generate a random graph in their own code and have a graph object?
My suggestion is to divide the current program into two parts.

  1. The functional core of Random Graph Generator in which graph specifications are passed to core functions and a Graph object is returned by functions.
  2. The executable wrapper of the functional core which is same as the current interface of pyrgg, uses the functional core and stores graphs in the files.

Steps/Code to Reproduce

Maybe these steps:

  1. Extract core functions and separate them for functional core
  2. Design Graph data model and class
  3. Connect the executable part to the core part

Expected Behavior

  • If someone needs the random graph generator as a library in which its functions return randomly generated graphs, they can use the functional core of pyrgg.
  • If someone just needs to execute the code and have a random graph in a file, they can use the executable part.

Logger enhancement

Description

Optimize logger function

Expected Behavior

2020-09-09 16:58:02
Filename : test2.gr
Vertices : 2
Total Edges : 4
Max Edge: x
Min Edge: x
Directed: True/False
Signed: True/False
Multigraph: True/False
Self Loop: True/False
Weighted: True/False
Max Weight: x
Min Weight: x
Elapsed Time : 00 days, 00 hour, 00 minutes, 20 seconds

Actual Behavior

2020-09-09 16:58:02.103878
Filename : test2.gr
Vertices : 2
Edges : 4
Elapsed Time : 00 days, 00 hour, 00 minutes, 20 seconds

Operating System

Windows 10

Python Version

3.5.2

Pyrgg Version

0.8

Format

Hi, are you going to support formats like MatrixMarket and SNAP?

Convert JSON numeric values to integers

Description

Currently when a new JSON graph is created all numeric values are written as strings even though they can be integers.

Expected Behavior

Have a JSON file with IDs, (including "source" and "target") as integers.

Actual Behavior

All those fields are strings

Pyrgg Version

v1.0

Graph-Line format bug

Description

Graph-Line format empty line should be removed

Steps/Code to Reproduce

>>> file=open('testfile.gl','r')
>>> print(file.read())

Expected Behavior

1 2:92
2 5:-155
3 10:148
4 7:-185
5 9:-128
6 1:93 9:-97
7 3:60
8 4:-44
10 10:114

Actual Behavior

1 2:92
2 5:-155
3 10:148
4 7:-185
5 9:-128
6 1:93 9:-97
7 3:60
8 4:-44
9
10 10:114

Operating System

Windows 10

Python Version

3.5.2

Pyrgg Version

0.8

Add directed graph support to JSON graphs

Description

When JSON files are generated using PyRGG, whether directed or not - there is no distinction in the JSON for it.

Expected Behavior

Add a new properties object to the root of the file which will contain details of the properties set in the generation such as:

  • directed
  • signed
  • multigraph
  • weighted
  • self loops
  • signed

All of those should be boolean variables.

Actual Behavior

Those properties can't be found currently.

Pyrgg Version

v1.0

Directed graph generation failed for yaml format

Description

The generated graph in yaml format is not a DAG graph, however, during configuration phase directed option is chosen. Please let me know if there is a solution to this issue. Please have a look at the generated file using the link below :

https://drive.google.com/file/d/1o2WODs34h2pwAeOgItcmTgjxT6mA0zjD/view?usp=sharing

You can find the loop in these nodes: [[4, 7, 10], [1, 5, 9]]

Expected Behavior

Directed acyclic graph

Actual Behavior

Looped graph

Operating System

Linux

Python Version

PYthon 3.7.5

Pyrgg Version

V1.0

Edge number bug

Description

Edge number is incorrect

Steps/Code to Reproduce

image

Expected Behavior

Total Number of Edges : 2

Actual Behavior

Total Number of Edges : 4

Operating System

Windows 10

Python Version

3.5.2

Pyrgg Version

0.8

Graph Plotting

Description

Sometimes it can be useful if we make a visualized output which helps the user making some sort of illustration about recently made graph.

It can be shown after each time of generation in pyrgg menu.
networkX has something like this, you can see it in the link bellow:
https://www.python-course.eu/networkx.php

GEXF Format

Description

GEXF Format

<?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>

Reference : https://github.com/gephi/gexf/wiki/Basic-Concepts#network-topology

Changing graph flag values

Description

In main menu each flag assigned by 1 or 2, but it seems more friendly if it changes to 0 or 1.
In second situation debugging may be more easy.
This issue may include these flags:

  • weighted
  • direct
  • self_loop
  • multigraph (which can be changed to singlegraph to seems more ordered)

console_scripts entry point

Description

Add console_scripts entry point to setup.py to run PyRGG directly from the terminal.

pyrgg

instead of

python -m pyrgg

Inaccurate metadata

Description

It has been observed that some metadata, such as max-weight, min-weight, max-edge, min-edge, self-loop, and multigraph, may contain inaccuracies.

We have two options:

  1. As some of the engines we are supporting lack controls on these parameters, we can remove the metadata.
  2. Write some functions that can accurately calculate this data.

Bug in generating of multigraphs

Description

Bug in generating of multigraphs

Steps/Code to Reproduce

image

Expected Behavior

Total Number of Edges ~ 10000

Actual Behavior

Total Number of Edges ~ 5

Operating System

Windows 10

Python Version

3.5.2

Pyrgg Version

0.8

import pyrgg as python library

Hi,

I am trying to use pyrgg with me own python application, could you please provide an example usage of importing pyrgg as a library in python?

Remove the 'graph' object from the JSON

Description

Currently when a new JSON graph is being generated, PyRGG generates a graph object which is redundant.

Expected Behavior

Have nodes and edges in the root of the JSON file:

{
    "nodes" : [
      {"id": "1"},
      {...}
    ],
    "edges" : [
      {    
        "source": "1",
        "target": "4",
        "weight": "8"
      },
      {...}
    ]
  }

If it is done because you are laying the ground for some future work regarding graph properties - you could maybe add a new properties objects at the JSON root.

Actual Behavior

{
  "graph" : {
    "nodes" : [
      {"id": "1"},
      {...}
    ],
    "edges" : [
      {    
        "source": "1",
        "target": "4",
        "weight": "8"
      },
      {...}
    ]
  }
}

Pyrgg Version

v1.0

Config file

Description

Save and load different configs in a config file

JOSS submission acceptance blockers

  • Missing statement of need: the software generates random graphs, but the user can only choose the number of vertices, min and max weight for the edges, and a range for a random number of edges. I would expect a useful random graph generator to provide some more options, like connectivity, min, max and avg degree.

  • Example usage: the README.md states that the output can be used as input to other programs, but have the files generated by this program ever been used as an input to some other algorithm? how?

  • Tests: no tests provided

  • Other:

Some formats are too slow

Description

Some formats are too slow :

  1. JSON
  2. YAML
  3. Pickle
  4. ASP
  5. TGF
  6. UCINET

Operating System

Windows 10

Python Version

Python 3.5.2

Pyrgg Version

0.5

`max_edge` not working.

Description

max_edge is not working as expected.

Steps/Code to Reproduce

csv_maker('testfile',0,100,10,0,3,True,True,False,False);print(open('testfile.csv','r').read())

Expected Behavior

Give an output with at most 3 edges.

Actual Behavior

It has got 11 edges as below:

>>> csv_maker('testfile',0,100,10,0,3,True,True,False,False);print(open('testfile.csv','r').read())
11
1,7,-64
2,10,-19
2,9,-76
2,8,-94
4,6,-14
4,5,35
5,1,-66
5,3,25
6,8,-26
9,3,-26
9,10,-15

Operating System

MacOS big sur.

Python Version

Python 3.9.12

Pyrgg Version

Pyrgg 1.1

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.