Exploring Different Graph Objects in Mathematica 8

I would like to automatically detect if a given object is Combinatorica or Mathematica 8.0 Graph.

It looks like FullForm has enough information to determine which one

(* output of Combinatorica`CompleteGraph[1] *) Graph[List[],List[List[List[0,0]]]] (* output of System`CompleteGraph[1] *) Graph[List[1],List[]] 

Mathematica, however, can tell them apart and display one as a text string and the other as a visual object. Does it exist

  • A way to view hidden information in expressions that are not displayed in FullForm.
  • How to watch the rules that Mathematica uses to render expressions?

Update : Head seems to give different results for the two graphs, even if the displayed chapters are identical. Defining a function as f [a_System'Graph] and f [a_Combinatorica'Graph] causes the correct version to be called

+4
source share
1 answer

The chapter returns different values โ€‹โ€‹for two types of graphs:

 In[1]:= g1 = Combinatorica`CompleteGraph[1]; In[2]:= g2 = System`CompleteGraph[1]; In[3]:= Combinatorica`Graph === Head[#] & /@ {g1, g2} Out[3]= {True, False} In[4]:= System`Graph === Head[#] & /@ {g1, g2} Out[4]= {False, True} 

As for question 1, you have limited options for viewing โ€œhiddenโ€ information in non-character objects such as graphics, images, etc. You can call Mathematica built-in functions that have access to the representation of a native object. There are functions specific to object types (for example, VertextCount or ImageDimensions) or more general (for example, CurrentValue or PropertyValue). You are at the mercy of MMA documentation to find comprehensive lists of such features. Alternatively, you can sometimes extract useful information by checking the expression of the cell of the output cell containing such an object. But it can hit or miss.

Regarding question 2, the WRI typically protects rendering rules for inline functions. In addition, some features (such as drawing tools and image editors) appear to be built directly into the laptop interface. You might be lucky to check boost values โ€‹โ€‹or down values โ€‹โ€‹on rendering functions such as MakeBoxes and Format, etc. Again, this is a bit or a miss.

+3
source

All Articles