class Graph
Attributes
underlying[R]
Public Class Methods
new(config, underlying=RGL::DirectedAdjacencyGraph.new)
click to toggle source
# File lib/graph.rb, line 6 def initialize(config, underlying=RGL::DirectedAdjacencyGraph.new) @config = config @underlying = underlying @edge_properties = {} @node_properties = {} end
Public Instance Methods
add_edge(from, to, opts)
click to toggle source
# File lib/graph.rb, line 19 def add_edge(from, to, opts) log("edge: #{from} -> #{to}") @underlying.add_edge(from, to) @edge_properties[[from, to]] = opts end
add_node(name, opts)
click to toggle source
# File lib/graph.rb, line 13 def add_node(name, opts) log("node: #{name}, opts: #{opts}") @underlying.add_vertex(name) @node_properties[name] = opts end
filter(source, destination)
click to toggle source
# File lib/graph.rb, line 25 def filter(source, destination) @underlying = GraphFilter.new(underlying).filter(source, destination) end
log(msg)
click to toggle source
# File lib/graph.rb, line 37 def log(msg) puts msg if @config.debug? end
output(renderer)
click to toggle source
# File lib/graph.rb, line 29 def output(renderer) @underlying.each_vertex { |v| renderer.add_node(v, @node_properties[v] || {}) } @underlying.each_edge { |u, v| renderer.add_edge(u, v, opts(u, v)) } renderer.output end
Private Instance Methods
opts(u, v)
click to toggle source
# File lib/graph.rb, line 42 def opts(u, v) @edge_properties[[u, v]] end