Module: GRATR::Labels
- Included in:
- Graph
- Defined in:
- lib/gratr/labels.rb
Instance Method Summary collapse
-
#[](u) ⇒ Object
Return a label for an edge or vertex.
-
#[]=(u, value) ⇒ Object
Set a label for an edge or vertex.
-
#clear_all_labels ⇒ Object
Delete all graph labels.
-
#delete_label(u) ⇒ Object
Delete a label entirely.
-
#edge_label(u, v = nil, n = nil) ⇒ Object
Get the label for an edge.
-
#edge_label_delete(u, v = nil, n = nil) ⇒ Object
Delete an edge label.
-
#edge_label_set(u, v = nil, l = nil, n = nil) ⇒ Object
Set the label for an edge.
-
#vertex_label(v) ⇒ Object
Get the label for an edge.
-
#vertex_label_delete(v) ⇒ Object
Delete a vertex label.
-
#vertex_label_set(v, l) ⇒ Object
Set the label for an edge.
Instance Method Details
#[](u) ⇒ Object
Return a label for an edge or vertex
31 |
# File 'lib/gratr/labels.rb', line 31 def [](u) (u.kind_of? GRATR::Arc) ? edge_label(u) : vertex_label(u); end |
#[]=(u, value) ⇒ Object
Set a label for an edge or vertex
34 |
# File 'lib/gratr/labels.rb', line 34 def []= (u, value) (u.kind_of? GRATR::Arc) ? edge_label_set(u,value) : vertex_label_set(u, value); end |
#clear_all_labels ⇒ Object
Delete all graph labels
58 |
# File 'lib/gratr/labels.rb', line 58 def clear_all_labels() @vertex_labels = {}; @edge_labels = {}; end |
#delete_label(u) ⇒ Object
Delete a label entirely
37 |
# File 'lib/gratr/labels.rb', line 37 def delete_label(u) (u.kind_of? GRATR::Arc) ? edge_label_delete(u) : vertex_label_delete(u); end |
#edge_label(u, v = nil, n = nil) ⇒ Object
Get the label for an edge
46 47 48 49 |
# File 'lib/gratr/labels.rb', line 46 def edge_label(u,v=nil,n=nil) u = edge_convert(u,v,n) edge_label_dict[u] end |
#edge_label_delete(u, v = nil, n = nil) ⇒ Object
Delete an edge label
61 62 63 64 |
# File 'lib/gratr/labels.rb', line 61 def edge_label_delete(u, v=nil, n=nil) u = edge_convert(u,v,n) edge_label_dict.delete(u) end |
#edge_label_set(u, v = nil, l = nil, n = nil) ⇒ Object
Set the label for an edge
52 53 54 55 |
# File 'lib/gratr/labels.rb', line 52 def edge_label_set(u, v=nil, l=nil, n=nil) u.kind_of?(GRATR::Arc) ? l = v : u = edge_convert(u,v,n) edge_label_dict[u] = l; self end |
#vertex_label(v) ⇒ Object
Get the label for an edge
40 |
# File 'lib/gratr/labels.rb', line 40 def vertex_label(v) vertex_label_dict[v]; end |
#vertex_label_delete(v) ⇒ Object
Delete a vertex label
67 |
# File 'lib/gratr/labels.rb', line 67 def vertex_label_delete(v) vertex_label_dict.delete(v); end |
#vertex_label_set(v, l) ⇒ Object
Set the label for an edge
43 |
# File 'lib/gratr/labels.rb', line 43 def vertex_label_set(v, l) vertex_label_dict[v] = l; self; end |