[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

RGL and changing propety of vertices and edges

meruby

4/17/2005 5:36:00 PM

I have basic program using rgl library which creates dot file and
display it using dotty.

*************************************************
require 'rgl/adjacency'
require 'rgl/dot'
dg = RGL::DirectedAdjacencyGraph[1,2 ,2,3 ,2,4, 4,5, 6,4, 1,6]
dg.dotty
*************************************************

I have modified this program to change default property as follows:

*************************************************
require 'rgl/adjacency'
require 'rgl/dot'
dg = RGL::DirectedAdjacencyGraph[1,2 ,2,3 ,2,4, 4,5, 6,4,
1,6].to_dot_graph("fontsize"=>30)
*************************************************


I have following questions:
1. How can I save/view this as dot file?
2. How can I apply property to vertices and edges
3. Is there any way I can add my own property key/value to vertices and
edges

Any small program will be wonderful help to ruby community who wants to
use this wonderful library.

3 Answers

Horst Duchene

4/20/2005 9:05:00 AM

0

meruby@gmail.com wrote:
> I have basic program using rgl library which creates dot file and
> display it using dotty.
>
> *************************************************
> require 'rgl/adjacency'
> require 'rgl/dot'
> dg = RGL::DirectedAdjacencyGraph[1,2 ,2,3 ,2,4, 4,5, 6,4, 1,6]
> dg.dotty
> *************************************************
>
> I have modified this program to change default property as follows:
>
> *************************************************
> require 'rgl/adjacency'
> require 'rgl/dot'
> dg = RGL::DirectedAdjacencyGraph[1,2 ,2,3 ,2,4, 4,5, 6,4,
> 1,6].to_dot_graph("fontsize"=>30)
> *************************************************
>
>
> I have following questions:
> 1. How can I save/view this as dot file?
Look at #write_to_graphic_file(fmt='png', dotfile="graph")
> 2. How can I apply property to vertices and edges
> 3. Is there any way I can add my own property key/value to vertices
and
> edges
As every object can be a vertex, you can use instance variables as
properties. Be careful to implement hash and eql? if using
RGL::DirectedAdjacencyGraph, because it uses hashes and sets for
implementing for adjacency lists.
>
> Any small program will be wonderful help to ruby community who wants
to
> use this wonderful library.

If I have more time I will give more examples at the the rgl wiki
(http://rgl.rubyforge.org/wi...). Meanwhile take a look in the
example directory of the distribution.

Cheers
Horst

G.Durga Prasad

4/20/2005 2:42:00 PM

0

On 4/20/05, Horst Duchene <monora@gmail.com> wrote:

> Cheers
> Horst
>
>
Wanted to try rgl , i am new to graphical libraries and dont know what is XML
I get this error after
gem install rgl

rgl-0.2.3]# rake
(in /usr/local/lib/ruby/gems/1.8/gems/rgl-0.2.3)
ruby -Ilib:tests -S testrb tests/TestTransitiveClosure.rb
tests/TestComponents.rb tests/TestDirectedGraph.rb
tests/TestGraphXML.rb tests/TestImplicit.rb
tests/TestUnDirectedGraph.rb tests/TestTraversal.rb tests/TestEdge.rb
Loaded suite [tests/TestTransitiveClosure.rb, tests/TestComponents.rb,
tests/TestDirectedGraph.rb, tests/TestGraphXML.rb,
tests/TestImplicit.rb, tests/TestUnDirectedGraph.rb,
tests/TestTraversal.rb, tests/TestEdge.rb]
Started
.............E.E...........................
Finished in 0.086025 seconds.

1) Error:
test_graphxml(TestGraphXML):
NoMethodError: undefined method `from_graphxml' for
RGL::DirectedAdjacencyGraph:Class
./tests/TestGraphXML.rb:22:in `test_graphxml'

2) Error:
test_north_graphs(TestGraphXML):
NoMethodError: undefined method `from_graphxml' for
RGL::DirectedAdjacencyGraph:Class
./tests/TestGraphXML.rb:38:in `test_north_graphs'
./tests/TestGraphXML.rb:35:in `open'
./tests/TestGraphXML.rb:35:in `test_north_graphs'
./tests/TestGraphXML.rb:28:in `foreach'
./tests/TestGraphXML.rb:28:in `test_north_graphs'

42 tests, 170 assertions, 0 failures, 2 errors
rake aborted!
what is missing, what should I do?
thanks,
Prasad



Horst Duchene

4/20/2005 9:10:00 PM

0

G.Durga Prasad wrote:

> On 4/20/05, Horst Duchene <monora@gmail.com> wrote:
>
>> Cheers
>> Horst
>>
>>
> Wanted to try rgl , i am new to graphical libraries and dont know what is
> XML I get this error after
For GraphML see http://rgl.sourceforge.net/files/rgl/graphx... for a
some explanation an links.
> gem install rgl
....
> Started
> ............E.E...........................
> Finished in 0.086025 seconds.
....
> what is missing, what should I do?
> thanks,
> Prasad

Nothing is missing. I think, the error is caused by a different load order
during the tests. In my environment (Debian GNU/Linux) the error does not
occur. Please try to run the testfile alone:

r40> ruby -rubygems tests/TestGraphXML.rb
Loaded suite tests/TestGraphXML
Started
...................................................................
Finished in 1.33859 seconds.

2 tests, 257 assertions, 0 failures, 0 errors

Cheers
Horst Duchene