Sha256: 6b587e2c29a7fed35b2dee56d42ee68281564ca29bf49a6c29e3a0a3c4c2ac6c
Contents?: true
Size: 873 Bytes
Versions: 34
Compression:
Stored size: 873 Bytes
Contents
require 'rgl/adjacency' class Graph attr_reader :underlying def initialize(config, underlying=RGL::DirectedAdjacencyGraph.new) @config = config @underlying = underlying @edge_properties = {} end def add_node(name) log("node: #{name}") @underlying.add_vertex(name) end def add_edge(from, to, opts) log("edge: #{from} -> #{to}") @underlying.add_edge(from, to) @edge_properties[[from, to]] = opts end def filter(source, destination) @underlying = GraphFilter.new(underlying).filter(source, destination) end def output(renderer) @underlying.each_vertex { |v| renderer.add_node(v) } @underlying.each_edge { |u, v| renderer.add_edge(u, v, opts(u, v)) } renderer.output end def log(msg) puts msg if @config.debug? end private def opts(u, v) @edge_properties[[u, v]] end end
Version data entries
34 entries across 34 versions & 1 rubygems