@@ -27,7 +27,8 @@ abstract type AbstractNode end
2727 AbstractExpressionNode{T} <: AbstractNode
2828
2929Abstract type for nodes that represent an expression.
30- This additionally must have fields for:
30+ Along with the fields required for `AbstractNode`,
31+ this additionally must have fields for:
3132
3233- `constant::Bool`: Whether the node is a constant.
3334- `val::T`: Value of the node. If `degree==0`, and `constant==true`,
103104Exactly the same as `Node{T}`, but with the assumption that some
104105nodes will be shared. All copies of this graph-like structure will
105106be performed with this assumption, to preserve structure of the graph.
107+ For example:
108+
109+ ```julia
110+ julia> operators = OperatorEnum(;
111+ binary_operators=[+, -, *], unary_operators=[cos, sin]
112+ );
113+
114+ julia> x = GraphNode(feature=1)
115+ x1
116+
117+ julia> y = sin(x) + x
118+ sin(x1) + {x1}
119+
120+ julia> cos(y) * y
121+ cos(sin(x1) + {x1}) * {(sin(x1) + {x1})}
122+ ```
123+
124+ Note how the `{}` indicates a node is shared, and this
125+ is the same node as seen earlier in the string.
106126"""
107127mutable struct GraphNode{T} <: AbstractExpressionNode{T}
108128 degree:: UInt8 # 0 for constant/variable, 1 for cos/sin, 2 for +/* etc.
@@ -131,12 +151,6 @@ constructorof(::Type{N}) where {N<:AbstractNode} = Base.typename(N).wrapper
131151constructorof (:: Type{<:Node} ) = Node
132152constructorof (:: Type{<:GraphNode} ) = GraphNode
133153
134- function with_type_parameters (:: Type{N} , :: Type{T} ) where {N<: AbstractExpressionNode ,T}
135- return constructorof (N){T}
136- end
137- with_type_parameters (:: Type{<:Node} , :: Type{T} ) where {T} = Node{T}
138- with_type_parameters (:: Type{<:GraphNode} , :: Type{T} ) where {T} = GraphNode{T}
139-
140154""" Trait declaring whether nodes share children or not."""
141155preserve_sharing (:: Type{<:AbstractNode} ) = false
142156preserve_sharing (:: Type{<:Node} ) = false
0 commit comments