3 # A simple graph library
7 # A container for all the parts of a graph. The graph can have arbitrary attributes,
8 # treated as method names.
9 class Graph
< OpenStruct
12 self.edges
= Array
.new
13 self.vertices
= Array
.new
17 # Add a Vertex or Edge to the graph.
19 if other
.class.ancestors
.include? Vertex
20 self.vertices
<< other
21 elsif other
.class.ancestors
.include? Edge