Macaulay2 » Documentation
Packages » EdgeIdeals :: isConnectedGraph
next | previous | forward | backward | up | index | toc

# isConnectedGraph -- determines if a graph is connected

- Usage:
    `b = isConnectedGraph G`
- Inputs:
  - G, a hypergraph,
- Outputs:
  - b, a Boolean value, true if G is connected, false otherwise

## Description

This function checks if the given graph G is connected. A graph is said to be connected if it has exactly one connected component.

Isolated vertices form their own connected components and will cause this method return false. This is in contrast to isConnected in which isolated vertices are not in any connected components. See the Connected Components Tutorial for more information.

    i1 : S = QQ[a..e];

    i2 : G = graph {a*b,b*c,c*d,d*e,a*e} -- the 5-cycle (connected)

    o2 = Graph{"edges" => {{a, b}, {b, c}, {c, d}, {a, e}, {d, e}}}
               "ring" => S
               "vertices" => {a, b, c, d, e}

    o2 : Graph

    i3 : H = graph {a*b,b*c,c*a,d*e} -- a 3-cycle and a disjoint edge (not connected)

    o3 = Graph{"edges" => {{a, b}, {a, c}, {b, c}, {d, e}}}
               "ring" => S
               "vertices" => {a, b, c, d, e}

    o3 : Graph

    i4 : isConnectedGraph G

    o4 = true

    i5 : isConnectedGraph H

    o5 = false

In the following example, the graph G has the isolated vertex e. As d forms its own connected component, this graph is not connected.

    i6 : S = QQ[a..e];

    i7 : G = graph {a*b,b*c,c*d,a*d} -- 4-cycle with isolated vertex (not connected)

    o7 = Graph{"edges" => {{a, b}, {b, c}, {a, d}, {c, d}}}
               "ring" => S
               "vertices" => {a, b, c, d, e}

    o7 : Graph

    i8 : isolatedVertices G

    o8 = {e}

    o8 : List

    i9 : isConnectedGraph G

    o9 = false

## See also

- Connected Components Tutorial -- clarifying the difference between graph and hypergraph components
- connectedGraphComponents -- returns the connected components of a graph
- isConnected -- determines if a (hyper)graph is connected
- isolatedVertices -- returns all vertices not contained in any edge
- numConnectedGraphComponents -- returns the number of connected components in a graph

## Ways to use isConnectedGraph:

- `isConnectedGraph(HyperGraph)`

## For the programmer

The object isConnectedGraph is a method function.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/EdgeIdeals.m2:3279:0.