Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.7K Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Inconsistency of TreeForm symbol depending on argument?

Posted 6 years ago

Hi, It seems TreeForm has different visual representation depending on arguments.

TreeForm[Graphics[{Circle[{0,0}],Disk[{2,2}]}]] works as it has to be.
TreeForm[Graph[{1->2,3->2}]] works completly differently.

Is it ok? Why TreeForm doesn't show Head and atoms in a second case as it does in the first one?

Two calls of TreeForm symbol

Attachment

Attachments:
POSTED BY: Roman Kozak
4 Replies
POSTED BY: Szabolcs Horvát

I suppose the situation is similar to the rational numbers: AtomQ[2/3] is True, but FullForm[2/3] is Rational[2, 3]. It feels like an inconsistency, and the matter was raised in the past in the forum. My vague recollection is that there must be a serious design issue behind it, but I don't know what it is.

POSTED BY: Gianluca Gorni
Posted 6 years ago

It's strange. If Graph is an atom than why we can browse Graph in FullForm?

In[57]:= FullForm@Graph[{1->2,3->2}]
Out[57]= Graph[List[1,2,3],List[DirectedEdge[1,2],DirectedEdge[3,2]]]

On the other hand, we can't change Head for Graph symbol also. So, is it Graph treated in a special way in Wolfram Language? If it's true then It may explain why TreeForm behaves in such a way.

In[58]:= FullForm[ Apply[f,Graph[{1->2,3->2}]] ]
Out[58]= Graph[List[1,2,3],List[DirectedEdge[1,2],DirectedEdge[3,2]]]

In[59]:= FullForm[ Apply[f,Graphics[{Circle[{0,0}],Disk[{2,2}]}]] ]
Out[59]= f[List[Circle[List[0,0]],Disk[List[2,2]]]]
POSTED BY: Roman Kozak

It seems that Graph objects are treated as atoms:

In[14]:= AtomQ[Graph[{1 -> 2, 3 -> 2}]]

Out[14]= True

You can look inside them with FullForm.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard