Map<String, dynamic> toMap() { return <String, dynamic>{ 'nodes': nodes.map((x) => x.toJson()).toList(), 'connections': connections.map((x) => x.toJson()).toList(), }; }