def data=(new_data)
@graph = Nanoc::DirectedGraph.new([ nil ] + @objects)
previous_objects = new_data[:vertices].map do |reference|
@objects.find { |obj| reference == obj.reference }
end
new_data[:edges].each do |edge|
from_index, to_index = *edge
from = from_index && previous_objects[from_index]
to = to_index && previous_objects[to_index]
@graph.add_edge(from, to)
end
new_objects = (@objects - previous_objects)
new_objects.each do |new_obj|
@objects.each do |obj|
next unless obj.is_a?(Nanoc::Item)
@graph.add_edge(new_obj, obj)
end
end
end