Closed emanuelhfarias closed 7 years ago
RGL does not support this out of the box. In RGL any object can be a vertex of a graph. Edges are simply a pair of objects (ordered in case of an DirectedGraph or unordered when the graph is undirected, see comment in DirectedEdge. If you want to store properties to edges you could either use property maps (similar to BGLs PropertyMaps) or subclass RGLs Edge classes. You could simply use standard ruby hash maps in your own graph implementation to attach properties to edges.
A simple mixin to provide this functionality could look like this:
require 'rgl/base'
module RGL
# A PropertyGraph can attach properties as key value pairs to vertices and edges.
#
module PropertyGraph
def put_vertex_property(v, key, value)
end
def get_vertex_property(v, key)
end
def put_edge_property(v, w, key, value)
end
def get_edge_property(v, w, key)
end
end
end
Could you give me an example of how to set properties to edges? Or an example of adding new edges with weight and other attributes?