Class: Graphm::Edge

Inherits:
Object
  • Object
show all
Defined in:
lib/graphm/edge.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src, dst, prop = {}) ⇒ Edge

Returns a new instance of Edge.



7
8
9
10
11
12
# File 'lib/graphm/edge.rb', line 7

def initialize src, dst, prop={}
  @src = src
  @dst = dst
  @prop = {}
  set_prop prop
end

Instance Attribute Details

#dstObject (readonly)

Returns the value of attribute dst.



5
6
7
# File 'lib/graphm/edge.rb', line 5

def dst
  @dst
end

#propObject (readonly)

Returns the value of attribute prop.



5
6
7
# File 'lib/graphm/edge.rb', line 5

def prop
  @prop
end

#srcObject (readonly)

Returns the value of attribute src.



5
6
7
# File 'lib/graphm/edge.rb', line 5

def src
  @src
end

Instance Method Details

#has_prop?(key, val = nil) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
# File 'lib/graphm/edge.rb', line 20

def has_prop? key, val=nil
  res = if @prop.include? key then
        @prop[key]
      else
        false
      end
  return res
end

#set_prop(prop) ⇒ Object



14
15
16
17
18
# File 'lib/graphm/edge.rb', line 14

def set_prop prop
  prop.each do |k,v|
    @prop[k] = v
  end
end