Sha256: 7216fd3094903e80f20f7ed58630f58fe52883844cb8734ce782024e13eb6105

Contents?: true

Size: 594 Bytes

Versions: 1

Compression:

Stored size: 594 Bytes

Contents

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'yargi'

COLORS = ["blue", "red", "yellow", "green"]

# We build a random graph with approximately 20 vertices
# and 60 edges (will be stripped by default). Each vertex
# will have a color picked at random.
graph = Yargi::Digraph.random(20,60) do |r|
  r.vertex_builder = lambda{|v,i|
    v[:color] = COLORS[Kernel.rand(COLORS.size)]
  }
end

# The label of each vertex will be its depth
Yargi::Decorate::DEPTH.execute(graph)
graph.vertices.add_marks{|v| {:label => v[:depth]}}

# Print as a dot graph
puts graph.to_dot

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yargi-0.2.0 examples/random.rb