deconstruct_node(((NodeVal,string(Shape)),ColVal),DefaultAttrs,ResNodeVal,Attrs,'$default_no_label') :-
valid_dot_shape(Shape),
!, % we have a triple (Node,"box","colour") = ((Node,"box"),"colour")
ResNodeVal=NodeVal,
translate_bvalue_to_colour(ColVal,ResColVal),
add_default_attrs(DefaultAttrs,[color/ResColVal,shape/Shape],Attrs).
deconstruct_node((NodeVal,string(ColVal)),DefaultAttrs,ResNodeVal,Attrs,'$default_no_label') :-
valid_rgb_color(ColVal),
!, % we have a pair (Node,"colour")
ResNodeVal=NodeVal,
add_default_attrs(DefaultAttrs,[color/ColVal],Attrs).
deconstruct_node((NodeVal,string(Shape)),DefaultAttrs,ResNodeVal, Attrs,'$default_no_label') :-
valid_dot_shape(Shape),
!, % we have a pair (Node,"shape")
ResNodeVal=NodeVal,
add_default_attrs(DefaultAttrs,[shape/Shape],Attrs).
deconstruct_node(Record,DefaultAttrs,NodeVal,
Attrs,Label) :-
% New record style: this should probably be the default now
extract_record_fields(Record,AllFields,DotAttributes,RemainingVals),
DotAttributes = [_|_], % at least one field recognised
( RemainingVals = [field(_,NodeVal)] -> true
; member(field(value,NodeVal),RemainingVals) -> true
; member(field(id,NodeVal),RemainingVals) -> true % like in VisB / SVG; note is also a valid dot_attribute_field
; RemainingVals=[], member(label/_,DotAttributes)
-> member(field(label,NodeVal),AllFields) % get original value before translation to string
% but using label as node value may not be ideal for linking edges, better use separate value/id field
; RemainingVals \= [] -> add_warning(state_custom_dot_graph,'Node has no label or value field:',Record,Record),
NodeVal = rec(RemainingVals)
),
!,
% add default values if not specified:
( select(label/LB,DotAttributes,Attrs0) -> Label=LB
; select(description/LB,DotAttributes,Attrs0) -> Label=LB
; Label = '$default_no_label', Attrs0=DotAttributes),
add_default_attrs(DefaultAttrs,Attrs0,Attrs).
deconstruct_node(NodeVal,DefaultAttrs,NodeVal,Attrs,'$default_no_label') :-
(DefaultAttrs=[]
-> format('CUSTOM_GRAPH_NODES value not recognised:~w~nUse rec(label:L,shape:"rect",...)~n',[NodeVal])
; true % user has provided attributes in outer rec(...) construct
),
add_default_attrs(DefaultAttrs,[],Attrs). % will remove none attributes