RGL and changing propety of vertices and edges

M

meruby

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.
 
H

Horst Duchene

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/wiki/wiki.pl). Meanwhile take a look in the
example directory of the distribution.

Cheers
Horst
 
G

G.Durga Prasad

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
 
H

Horst Duchene

G.Durga Prasad said:
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/graphxml_rb.html 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,607
Members
45,241
Latest member
Lisa1997

Latest Threads

Top