Skip to main content
This page is documentation for a DEVELOPMENT / PRE-RELEASE version. Switch to stable version
Ctrl+K

NetworkX User Survey 2023 🎉 Fill out the survey to tell us about your ideas, complaints, praises of NetworkX!

Logo image

Site Navigation

  • Install
  • Tutorial
  • Reference
  • Gallery
  • Developer
  • Releases
  • Guides
    • devel (latest)
    • current (stable)

Site Navigation

  • Install
  • Tutorial
  • Reference
  • Gallery
  • Developer
  • Releases
  • Guides
    • devel (latest)
    • current (stable)

Section Navigation

  • Introduction
  • Graph types
  • Algorithms
    • Approximations and Heuristics
    • Assortativity
    • Asteroidal
    • Bipartite
    • Boundary
    • Bridges
    • Centrality
    • Chains
    • Chordal
    • Clique
    • Clustering
    • Coloring
    • Communicability
    • Communities
    • Components
    • Connectivity
    • Cores
    • Covering
    • Cycles
    • Cuts
    • D-Separation
    • Directed Acyclic Graphs
    • Distance Measures
    • Distance-Regular Graphs
    • Dominance
    • Dominating Sets
    • Efficiency
    • Eulerian
    • Flows
    • Graph Hashing
    • Graphical degree sequence
    • Hierarchy
    • Hybrid
    • Isolates
    • Isomorphism
    • Link Analysis
    • Link Prediction
    • Lowest Common Ancestor
    • Matching
    • Minors
    • Maximal independent set
    • non-randomness
    • Moral
    • Node Classification
    • Operators
    • Planarity
    • Planar Drawing
    • Graph Polynomials
    • Reciprocity
    • Regular
    • Rich Club
    • Shortest Paths
    • Similarity Measures
    • Simple Paths
    • Small-world
    • s metric
    • Sparsifiers
    • Structural holes
    • Summarization
    • Swap
    • Threshold Graphs
    • Tournament
    • Traversal
    • Tree
    • Triads
    • Vitality
    • Voronoi cells
    • Wiener index
  • Functions
  • Graph generators
  • Linear algebra
  • Converting to and from other data formats
  • Relabeling nodes
  • Reading and writing graphs
  • Drawing
  • Randomness
  • Exceptions
  • Utilities
  • Glossary
  • Reference
  • Components
  • is_connected

is_connected#

is_connected(G)[source]#

Returns True if the graph is connected, False otherwise.

Parameters:
GNetworkX Graph

An undirected graph.

Returns:
connectedbool

True if the graph is connected, false otherwise.

Raises:
NetworkXNotImplemented

If G is directed.

See also

is_strongly_connected
is_weakly_connected
is_semiconnected
is_biconnected
connected_components

Notes

For undirected graphs only.

Examples

>>> G = nx.path_graph(4)
>>> print(nx.is_connected(G))
True
Ctrl+K
On this page
  • is_connected()

© Copyright 2004-2023, NetworkX Developers.

Created using Sphinx 6.1.3.

Built with the PyData Sphinx Theme 0.13.1.