Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Even if in

Graph[{1 -> 2}] == Graph[{1 \[DirectedEdge] 2}]

the answer is True ; but why MMA doesn't show the result of the following expression?Neither True nor False.What is the reason?

{1 -> 2} == {1 \[DirectedEdge] 2}
share|improve this question

1 Answer 1

up vote 1 down vote accepted

You can often figure this kind of thing out by looking at the FullForm of the expressions. In this case:

{FullForm[{1 -> 2}], FullForm[{1 \[DirectedEdge] 2}]}

shows that the first is a Rule while the second is a DirectedEdge and hence they are not equal. On the other hand, when embedded inside Graph, both sides become

Graph[List[1, 2], List[DirectedEdge[1, 2]]]

and hence are equal.

share|improve this answer
    
Thanks but then why it doesn't show the False? –  Alex Oct 3 '13 at 0:23
1  
It shows True when both sides are the same. It shows False when the two sides are different. To see the False use the triple equals: {1 -> 2} === {1 \[DirectedEdge] 2}does indeed return False. It's the difference between "equals" and "identical" or Equals and SameQ. –  bill s Oct 3 '13 at 0:32
2  
@Alex As bill s says, == and === are different and you probably were looking for ===. Also see: Evaluating an If condition to yield True/False –  rm -rf Oct 3 '13 at 1:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.