I want to create a property list to build up a graph using adjacent list representation.
So in the property list, I want to have a dictionary ([String: Array]). The string will be the node, the array will store its neighbors. Inside the Array, I would like to have (String, Int) tuples, the String for the neighbor, the Int for the weight (each tuple represents an edge incident to the node).
The problem is that I cannot have tuples inside Property List. I could use Dictionary, but it seems an array of dictionary with only one item inside that dictionary is not worth it. Any better solutions? Thanks!
How about this
let node = "node"
let incident = ( "edge1", 12 )
var dictionary:[String:Array<Any>] = [:]
dictionary[node] = [ incident.0, incident.1 ]
This should give you a dictionary with a string and an array from your tuples