# What is a “graph object”? [closed]

I typed the following on Mathematica:

I am confused: How come those graphs are not connected? Trying to debug it, I tried to use other graph functions such as GraphDistanceMatrix and it yields:

So it seems the problem is that those are not "graph objects". I also tried:

But that also doesn't convert it to a graph object. I tried to look up the help but nothing relevant appeared.

• M and U are adjacency matrices, and not graphs. You want to apply AdjacencyGraph[] to get something that has the head Graph. – J. M.'s technical difficulties Jun 2 at 8:17
• In addition to what @J.M. said: A graph object is any expression where GraphQ returns True – Lukas Lang Jun 2 at 9:36

M and U in your example are matrices, not graphs. You can use AdjacencyGraph to create a graph from them.

The output of GraphPlot is a Graphics expression, not a Graph expression.

We use the term "graph expression" to denote the data structure that Mathematica uses to represent graphs.

A graph expression will always have Head Graph.

GraphQ[g] returns True if and only if g is a graph expression. Usually, we simply say that "g is a graph" (not a matrix, not a list of edges, not a picture showing a graph, but a graph).

Almost all functions whose name ends in Q always return either True or False in Mathematica. Thus, ConnectedGraphQ will:

• return True for a connected graph
• return False for a non-connected graph
• return False (without an error message!) for anything that is not a graph