30 May 2009

Random graph generation example

Have been playing around with the beautiful ocamlgraph library. I also installed xmlrpc-light to draw graph through the free version of the ubigraph server.

I wrote a tool to generate some random graph. The goal is to render graph that have the same connectivity caracteristics as social networks. The generation algorithm is inspired of the forest fire model for graph generation (propagate links to neighboorhood recursively).

The code is online. All is in single file socnet.ml, but I use code from xmlrpc-light library for Ubigraph calls. There is a Builder module to augment the default builder of ocamlgraph with a state; a special UbigraphBuilder to replicate the graph structure for rendering; and finally the algo to generate the graph is in Gen module.

The result is a single binary:


./socnet.byte
  [-n <node-number>]
  [-gv] [-ubi]
  [-fwd <forward-factor>] [-bck <backward-factor>] [-bi <linking-back-factor>]

When creating an edge from a source node to some target node:

  • forward factor is related to the probability to link source node to successors of a target node
  • backward factor is related to the probability to link source node to predecessors of a target node
  • linking back factor is related to probability to create an edge from target node to source node

Following are some screenshots of results, although it is much more interesting to watch the construction steps though Ubigraph renderer.


./socnet.byte -n 12 -bi 0.0 -gv


./socnet.byte -n 12 -gv


./socnet.byte -n 800 -bi 0.0 -ubi


./socnet.byte -n 800 -ubi

blog comments powered by Disqus