@@ -218,13 +218,20 @@ end
218218Base. eltype (:: Type{<:AbstractExpressionNode{T}} ) where {T} = T
219219Base. eltype (:: AbstractExpressionNode{T} ) where {T} = T
220220
221- max_degree (:: Type{<:AbstractNode} ) = 2 # Default
221+ const DEFAULT_MAX_DEGREE = 2
222+ max_degree (:: Type{<:AbstractNode} ) = DEFAULT_MAX_DEGREE
222223max_degree (:: Type{<:AbstractNode{D}} ) where {D} = D
223224max_degree (node:: AbstractNode ) = max_degree (typeof (node))
224225
225- @unstable constructorof (:: Type{N} ) where {N<: Node } = Node{T,max_degree (N)} where {T}
226- @unstable constructorof (:: Type{N} ) where {N<: GraphNode } =
227- GraphNode{T,max_degree (N)} where {T}
226+ has_max_degree (:: Type{<:AbstractNode} ) = false
227+ has_max_degree (:: Type{<:AbstractNode{D}} ) where {D} = true
228+
229+ @unstable function constructorof (:: Type{N} ) where {N<: Node }
230+ return Node{T,max_degree (N)} where {T}
231+ end
232+ @unstable function constructorof (:: Type{N} ) where {N<: GraphNode }
233+ return GraphNode{T,max_degree (N)} where {T}
234+ end
228235
229236function with_type_parameters (:: Type{N} , :: Type{T} ) where {N<: Node ,T}
230237 return Node{T,max_degree (N)}
@@ -233,6 +240,9 @@ function with_type_parameters(::Type{N}, ::Type{T}) where {N<:GraphNode,T}
233240 return GraphNode{T,max_degree (N)}
234241end
235242
243+ with_max_degree (:: Type{N} , :: Val{D} ) where {T,N<: Node{T} ,D} = Node{T,D}
244+ with_max_degree (:: Type{N} , :: Val{D} ) where {T,N<: GraphNode{T} ,D} = GraphNode{T,D}
245+
236246function default_allocator (:: Type{N} , :: Type{T} ) where {N<: AbstractExpressionNode ,T}
237247 return with_type_parameters (N, T)()
238248end
0 commit comments