xxxxxxxxxx
// By default maps in Go behaves like a default dictionary in python
m := make(map[string]int)
m["Dio"] = 3
m["Jonathan"] = 1
xxxxxxxxxx
//Use a constructor-like function to initialize a map found inside a struct
//Struch with map inside
type Graph struct {
connections map[Vertex][]Vertex
}
//Constructor function
func NewGraph() *Graph {
var g Graph
g.connections = make(map[Vertex][]Vertex)
return &g
}
//Declare and initialize the struct instance with the constructor
func main(){
graph := NewGraph()
}