Module: RGFATools::SuperfluousLinks
- Included in:
- RGFATools
- Defined in:
- lib/rgfatools/superfluous_links.rb
Overview
Methods which edit the graph components without traversal
Instance Method Summary collapse
-
#enforce_all_mandatory_links(conserve_components: true) ⇒ RGFA
Remove superfluous links in the presence of mandatory links in the entire graph.
-
#enforce_segment_mandatory_links(segment, conserve_components: true) ⇒ RGFA
Remove superfluous links in the presence of mandatory links for a single segment.
-
#remove_self_link(segment) ⇒ RGFA
Remove links of segment to itself.
-
#remove_self_links ⇒ RGFA
Remove all links of segments to themselves.
Instance Method Details
#enforce_all_mandatory_links(conserve_components: true) ⇒ RGFA
Remove superfluous links in the presence of mandatory links in the entire graph
42 43 44 45 46 |
# File 'lib/rgfatools/superfluous_links.rb', line 42 def enforce_all_mandatory_links(conserve_components: true) segment_names.each {|sn| enforce_segment_mandatory_links(sn, conserve_components: conserve_components)} self end |
#enforce_segment_mandatory_links(segment, conserve_components: true) ⇒ RGFA
Remove superfluous links in the presence of mandatory links for a single segment
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rgfatools/superfluous_links.rb', line 13 def enforce_segment_mandatory_links(segment, conserve_components: true) sn = segment_and_segment_name(segment)[1] se = {} l = {} [:B, :E].each do |et| se[et] = [sn, et] l[et] = links_of(se[et]) end cs = connectivity_symbols(l[:B].size, l[:E].size) if cs == [1, 1] oe = {} [:B, :E].each {|et| oe[et] = l[et][0].other_end(se[et])} return if oe[:B] == oe[:E] [:B, :E].each {|et| delete_other_links(oe[et], se[et], conserve_components: conserve_components)} else i = cs.index(1) return if i.nil? et = [:B, :E][i] oe = l[et][0].other_end(se[et]) delete_other_links(oe, se[et], conserve_components: conserve_components) end self end |
#remove_self_link(segment) ⇒ RGFA
Remove links of segment to itself
51 52 53 54 55 |
# File 'lib/rgfatools/superfluous_links.rb', line 51 def remove_self_link(segment) segment_name = segment.kind_of?(RGFA::Line) ? segment.name : segment unconnect_segments(segment_name, segment_name) self end |
#remove_self_links ⇒ RGFA
Remove all links of segments to themselves
59 60 61 62 |
# File 'lib/rgfatools/superfluous_links.rb', line 59 def remove_self_links segment_names.each {|sn| remove_self_link(sn)} self end |