Working with a directed graph using RGL in Ruby -
I have implemented a guided graph in Ruby using RGL, just to find out for a given node How difficult is the nodes with incoming connections and nodes with outgoing connections, I'm probably missing something simple.
I could just run into this problem that this might possibly work, though this is the most beautiful approach Can not be:
is required 'rgl / adjacency' requirement 'RGL / bidirectional' class RGL :: guided disableability graph DRAF_Ideal (V) rdg = self .reverse rdg.adjacent_vertices ( V) .size end def out_degree (v) self.adjacent_vertices (v) .size end end dg = RGL :: guided engage graph [1,2, 2,3, 2,4, 4,5, 6, 4, 1,6 ] P dg.in_degree (2) # = & gt; 2p dg.out_degree (2) # = & gt; 1p dg.in_degree (1) # = & gt; 0 p dg.out_degree (3) # = & gt; 0
The long answer is that it has not yet been implemented.
The way it works, it's RGL :: bidirectional module, along with your guided graph class, it will give you all the important all_in_elegant methods. Therefore something should be done in this way (but not):
is required 'rgl / adjacency' requirement 'RGL / bidirectional' class RGL :: guidedgegegraphrg RGL :: bidirectional graph end DG = RGL:: Directedgegegraph [1,2, 2,3, 2,4, 4,5, 6,4, 1,6] dg.vertices # = & gt; [5, 6, 1, 2, 3, 4] p dg.adjacent_vertices (2) # = & gt; [3, 4] p dg.each_in_neighbor (2) # = & gt; NotImplementedError: (# = & gt; should be: [1]
I have not dug the code to see how much work it will be, but it can be a better option Your needs.
Edit: I forgot to mention that the properties of the source and the target are not available for a degree degree node. But an alternative approach to collect and compare all the edges from the graph To see them for F any of them have node of interest as a target.
Comments
Post a Comment