Take the simple graph {1->2, 2->3, 3->1}:

TreePlot[{1->2,2->3,3->1}]

I would expect that WeaklyConnectedGrapghQ[{1->2,2->3,3->1}] evaluates to True, but in fact I get False, so I was wondering if maybe my concept of connectet graph is wrong. Is this graph (weakly) connected or Mathematica is right and the correct output is False?.

=================

Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!

– Michael E2

Oct 17 ’15 at 12:49

=================

1 Answer

1

=================

In general, all functions ending in Q will return either True or False, but nothing else.

You can think of WeaklyConnectedGraphQ as testing that it’s argument is a graph and that it is weakly connected.

{1->2,2->3,3->1} is not a graph, it is a list of rules. Thus WeaklyConnectedGraphQ returns False.

g = Graph[{1->2,2->3,3->1}] creates a graph from the rule list. WeaklyConnectedGraphQ[g] returns True.

This is it, thank you.

– AccidentalFourierTransform

Oct 17 ’15 at 13:23