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

Version Path
aws_security_viz-0.1.7.pre.alpha.pre.145 lib/graph.rb
aws_security_viz-0.1.7.pre.alpha.pre.138 lib/graph.rb
aws_security_viz-0.1.7.pre.alpha.pre.136 lib/graph.rb
aws_security_viz-0.1.6.pre.alpha.pre.134 lib/graph.rb
aws_security_viz-0.1.6 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.133 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.131 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.130 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.112 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.111 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.110 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.109 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.108 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.107 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.106 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.103 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.102 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.101 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.100 lib/graph.rb
aws_security_viz-0.1.5.pre.alpha.pre.99 lib/graph.rb