Skip to content

Commit 947ec97

Browse files
committed
Add method for Node with id, parent and NodeMTG
1 parent fb07197 commit 947ec97

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/types/Node.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,14 @@ end
122122
# Only the MTG is given, by default we use Dict as attributes:
123123
Node(MTG::T) where {T<:AbstractNodeMTG} = Node(1, MTG, Dict{Symbol,Any}())
124124

125-
# Only the MTG and parent are given, by default we use the parent attribute type:
125+
# Only the ID, MTG and parent are given, by default we use the parent attribute type:
126+
function Node(id::Int, parent::Node{N,A}, MTG::T) where {N<:AbstractNodeMTG,A,T<:AbstractNodeMTG}
127+
Node(id, parent, MTG, A())
128+
end
129+
130+
# Same but without the id:
126131
function Node(parent::Node{N,A}, MTG::T) where {N<:AbstractNodeMTG,A,T<:AbstractNodeMTG}
127-
Node(parent, MTG, A())
132+
Node(new_id(get_root(parent)), parent, MTG, A())
128133
end
129134

130135
# Copying a node returns the node:

0 commit comments

Comments
 (0)