Serializes an object
@override Map<String, dynamic> toJson() => {'source': source.toJson(), 'target': target.toJson(), 'weight': weight};