Fork Me on GitHub

Graphshaper

Generate realistic graphs

download .ZIPdownload .TGZ

So you want to shape a graph...

Imagine sitting on your computer in desperate need for a graph. You toss and you turn – where do I get a realistic graph? Graphshaper to the rescue – your all-in-one solution for generating scale-free networks.

Why would I ever want to do that?

I created this gem for my bachelor thesis, where I will implement certain graph algorithms in the new NoSQL database AvocadoDB. I will compare the performance to existing solutions, therefore I need the same graph in different database systems. And – of course – I need some pretty pictures for my thesis, so I included an export to PNG via dot.

What do you mean when you say realistic?

If you would generate a bunch of vertices and then connect them with vertices at random, you don't get a realistic network. Most real world, large networks follow the power-law in their node distribution. To generate a graph that has the same attributes, graphshaper uses an algorithm based upon the Barabási-Albert model introduced by R. Albert and A.-L. Barabási in 2002.

Ok, and how would I generate a graph now?

First you would install graphshaper from ruby gems. You can either do that via gem install graphshaper or – in your bundler file – via gem 'graphshaper', '~> 0.2.2'. You can either use graphshaper via the command line or in your Ruby code as a library. For the latter I refer you to the documentation. The commandline tool expects one argument: The number of vertices you want your generated graph to have. This is how to use it:

graphshaper [options] size

You can use the following options:

Format Support

Currently you can only export the graph to CSV, AvocadoDB and the dot format. You can of course use the CSV files to import them into any system, but I will also add support for more systems (MySQL and Neo4j) very soon. If you need any other format or system, feel free to send me a (well rspec'ed) pull request :)