Module: Evoc::Util
- Defined in:
- lib/evoc/util.rb
Class Method Summary collapse
Class Method Details
.lattice(nodes, filter: nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/evoc/util.rb', line 8 def self.lattice(nodes,filter: nil) (1..nodes.size).each do |n| nodes.combination(n).each do |comb| # [['a',[1,2]],['b',[2,3]]] union = comb.map(&:first).join(',') frequency = comb.map(&:second).inject(&:&).size if filter =~ union if frequency > 0 printf("%#{nodes.size*2}s",[union,frequency].join(':')) end end end puts end end |
.nodes2txstore(nodes) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/evoc/util.rb', line 27 def self.nodes2txstore(nodes) txes = nodes.map(&:second).inject(&:|) store = Evoc::TxStore.new txes.each do |id| items = nodes.select {|n| n.second.include?(id)}.map(&:first) store << Evoc::Tx.new(id: id, items: items) end return(store) end |