12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576(**************************************************************************)(* *)(* This file is part of OcamlGraph. *)(* *)(* Copyright (C) 2009-2010 *)(* CEA (Commissariat � l'�nergie Atomique) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1, with a linking exception. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the file ../LICENSE for more details. *)(* *)(* Authors: *)(* - Julien Signoles (Julien.Signoles@cea.fr) *)(* - Jean-Denis Koeck (jdkoeck@gmail.com) *)(* - Benoit Bataille (benoit.bataille@gmail.com) *)(* *)(**************************************************************************)letelement=function|[]->invalid_arg"empty list in element"|l->Random.self_init();List.nthl(Random.int(List.lengthl))letblack=0x000000andwhite=0xFFFFFFandred=0xFF0000andgreen=0x00FF00andblue=0x0000FFandyellow=0xFFFF00andcyan=0x00FFFFandmagenta=0xFF00FFmoduleVertex=structtypet=intendmoduleEdge=structtypet=intletcompare:int->int->int=Stdlib.compareletdefault=0endmoduleG=Imperative.Digraph.AbstractLabeled(Vertex)(Edge)moduleR=Rand.I(G)moduleGraphAttrs=structincludeGletgraph_attributes_=[]letdefault_vertex_attributes_=[]letvertex_namev=string_of_int(G.V.labelv)letvertex_attributes_=letshape=element[`Ellipse;`Box;`Circle;`Doublecircle;`Diamond]inletcolor=element[black;white;red;green;blue;yellow;cyan;magenta]in[`Shapeshape;`Colorcolor]letdefault_edge_attributes_=[]letedge_attributes_=[]letget_subgraph_=NoneendmoduleModel=DGraphModel.Make(GraphAttrs)letcreate()=(* State *)Random.self_init();letv=100inlete=Random.int(v*2)inletg=R.graph~loops:true~v~e()inModel.from_graphg