Class: HG::Hypergraph

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nodes = [], edges = []) ⇒ Hypergraph

Returns a new instance of Hypergraph.



27
28
29
30
# File 'lib/zipf/hypergraph.rb', line 27

def initialize nodes=[], edges=[]
  @nodes = nodes
  @edges = edges
end

Instance Attribute Details

#edgesObject

Returns the value of attribute edges.



25
26
27
# File 'lib/zipf/hypergraph.rb', line 25

def edges
  @edges
end

#nodesObject

Returns the value of attribute nodes.



25
26
27
# File 'lib/zipf/hypergraph.rb', line 25

def nodes
  @nodes
end

Instance Method Details

#arityObject



32
33
34
# File 'lib/zipf/hypergraph.rb', line 32

def arity
  @edges.map { |e| e.arity }.max
end

#to_sObject



36
37
38
# File 'lib/zipf/hypergraph.rb', line 36

def to_s
  "Hypergraph<nodes:[#{@nodes.to_s}], edges:[#{@edges.to_s}], arity:#{arity}>"
end