Class: HG::Hyperedge

Inherits:
Object
  • Object
show all
Defined in:
lib/zipf/hypergraph.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(head = nil, tails = [], weight = 0.0, f = {}) ⇒ Hyperedge

Returns a new instance of Hyperedge.



44
45
46
47
48
49
50
# File 'lib/zipf/hypergraph.rb', line 44

def initialize head=nil, tails=[], weight=0.0, f={}
  @head   = head
  @tails  = tails
  @weight = weight
  @f      = f
  @mark   = 0
end

Instance Attribute Details

#fObject

Returns the value of attribute f.



42
43
44
# File 'lib/zipf/hypergraph.rb', line 42

def f
  @f
end

#headObject

Returns the value of attribute head.



42
43
44
# File 'lib/zipf/hypergraph.rb', line 42

def head
  @head
end

#leftObject

Returns the value of attribute left.



42
43
44
# File 'lib/zipf/hypergraph.rb', line 42

def left
  @left
end

#markObject

Returns the value of attribute mark.



42
43
44
# File 'lib/zipf/hypergraph.rb', line 42

def mark
  @mark
end

#rightObject

Returns the value of attribute right.



42
43
44
# File 'lib/zipf/hypergraph.rb', line 42

def right
  @right
end

#ruleObject

Returns the value of attribute rule.



42
43
44
# File 'lib/zipf/hypergraph.rb', line 42

def rule
  @rule
end

#tailsObject

Returns the value of attribute tails.



42
43
44
# File 'lib/zipf/hypergraph.rb', line 42

def tails
  @tails
end

#weightObject

Returns the value of attribute weight.



42
43
44
# File 'lib/zipf/hypergraph.rb', line 42

def weight
  @weight
end

Instance Method Details

#arityObject



52
53
54
# File 'lib/zipf/hypergraph.rb', line 52

def arity
  return @tails.size
end

#marked?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/zipf/hypergraph.rb', line 56

def marked?
  arity == @mark
end

#to_sObject



60
61
62
# File 'lib/zipf/hypergraph.rb', line 60

def to_s
  "Hyperedge<head:\"#{@head.label}\", \"tails:#{@tails.map{|n|n.label}}, arity:#{arity}, weight:#{@weight}, f:#{f.to_s}, mark:#{@mark}>"
end