From: Horst Duchene Date: 2002-11-14T06:58:15+09:00 Subject: Re: RGL - how to add attributes to Dot vertices? "Booth, Peter" schrieb im Newsbeitrag news:0F17ACE0B516D51194BC009027FC497D1AE19B45@gsny43e.ny.fw.gs.com... Hello, > Is anyone using RGL and to draw graphs? I was able to install and get basic > graphs going in a few minutes, but can't see how to customize the appearance of > vertices. > > Is there a way of defining attributes of nodes in an > RGL::DirectedAdjacencyGraph so that > > the generated Dot output uses distinct shapes / colors etc ? RGL uses a variation of dot.rb coming with RDoc (http://rdoc.sf.net). The file is called rdot.rb in the RGL-Distribution to avoid confusion when both libraries are installed. In rdot.rb defines classes DOTNode and DOTEdge which allow nearly all features of Graphviz (http://www.research.att.com/sw/tools/graphviz/download.html) to customize appearance. RGL's Graph#to_dot_graph (in rgl/dot.rb) allows to change the attributes of the appearance of the whole graph (all attributes listed in DOT::GRAPH_OPTS are allowed): RGL::DirectedAdjacencyGraph[1,2 ,2,3 ,2,4].to_dot_graph ("fontsize"=>30) will use fontsize 30 for all vertices instead of the default of 8. To change the appearance of single vertices (or edges) you have to improve the method to_dot_graph which uses default attributes for vertices and nodes. Since vertices of RGL Graphs can be any ruby object you could store the graphical attributes in the vertex object and convert them in your own Graph#to_dot_graph to appropriate graphviz attributes. An alternative could be to have a method Object#to_dot_node which would return a DOT::DOTNode. Cheers Horst