WLJS LogoWLJS Notebook

ConnectedGraphQ

ConnectedGraphQ[g] yields True if graph g is connected (every vertex can reach every other vertex), and False otherwise.

Examples

Test connectivity:

ConnectedGraphQ[Graph[{1 <-> 2, 2 <-> 3}]]
(* True *)

ConnectedGraphQ[Graph[{1 <-> 2, 3 <-> 4}]]
(* False - two disconnected components *)

Complete graphs are connected:

ConnectedGraphQ[CompleteGraph[10]]
(* True *)

Please visit the official Wolfram Language Reference for more details.

On this page