diff --git a/al.go b/al.go index ace990d..a955bef 100644 --- a/al.go +++ b/al.go @@ -18,7 +18,7 @@ import ( "sync" ) -type al map[Vertex]VertexSet +type al map[Vertex]map[Vertex]struct{} // Helper to not have to write struct{} everywhere. var keyExists = struct{}{} @@ -105,13 +105,13 @@ func (g *adjacencyList) EnsureVertex(vertices ...Vertex) { func (g *adjacencyList) ensureVertex(vertices ...Vertex) { // TODO this is horrible, but the reflection approach in the testing harness requires it...for now if g.list == nil { - g.list = make(map[Vertex]VertexSet) + g.list = make(map[Vertex]map[Vertex]struct{}) } for _, vertex := range vertices { if !g.hasVertex(vertex) { // TODO experiment with different lengths...possibly by analyzing existing density? - g.list[vertex] = make(VertexSet, 10) + g.list[vertex] = make(map[Vertex]struct{}, 10) } } diff --git a/directed.go b/directed.go index 1378425..b1a0a43 100644 --- a/directed.go +++ b/directed.go @@ -8,7 +8,7 @@ type Directed struct { func NewDirected() *Directed { list := &Directed{} // Cannot assign to promoted fields in a composite literals. - list.list = make(map[Vertex]VertexSet) + list.list = make(map[Vertex]map[Vertex]struct{}) // Type assertions to ensure interfaces are met var _ Graph = list diff --git a/undirected.go b/undirected.go index 2243580..b27887d 100644 --- a/undirected.go +++ b/undirected.go @@ -11,7 +11,7 @@ type Undirected struct { func NewUndirected() *Undirected { list := &Undirected{} // Cannot assign to promoted fields in a composite literals. - list.list = make(map[Vertex]VertexSet) + list.list = make(map[Vertex]map[Vertex]struct{}) // Type assertions to ensure interfaces are met var _ Graph = list