How to convert following graph into 'set'. Because i have one graph. i need to check that graph is subset of this graph.
require 'rgl/adjacency'
dg = RGL::DirectedAdjacencyGraph[1,2,3,4,5,6,3,2,4]
thanks.
How to convert following graph into 'set'. Because i have one graph. i need to check that graph is subset of this graph.
require 'rgl/adjacency'
dg = RGL::DirectedAdjacencyGraph[1,2,3,4,5,6,3,2,4]
thanks.
The to_set
method will do it for you.
require 'rgl/adjacency'
dg = RGL::DirectedAdjacencyGraph[1,2,3,4,5,6,3,2,4]
dg_subgraph = RGL::DirectedAdjacencyGraph[1,2]
dg_subgraph.to_set.subset? dg.to_set # => true
Why?
As per https://github.com/javanthropus/rgl/blob/master/lib/rgl/adjacency.rb#L11
The class for representing the adjacency list of a vertex is, by default, a Set
unless you have configured it otherwise.