Skip to main content
Ctrl+K
NetworkX 3.2.1 documentation - Home
  • Install
  • Tutorial
  • Reference
  • Gallery
  • Developer
  • Releases
  • Guides
  • Home Page
  • GitHub
  • Install
  • Tutorial
  • Reference
  • Gallery
  • Developer
  • Releases
  • Guides
  • Home Page
  • GitHub

Section Navigation

  • Basic
  • Drawing
    • Custom Node Position
    • Chess Masters
    • Custom node icons
    • Degree Analysis
    • Directed Graph
    • Edge Colormap
    • Ego Graph
    • Eigenvalues
    • Four Grids
    • House With Colors
    • Knuth Miles
    • Labels And Colors
    • Multipartite Layout
    • Node Colormap
    • Rainbow Coloring
    • Random Geometric Graph
    • Sampson
    • Self-loops
    • Simple Path
    • Spectral Embedding
    • Traveling Salesman Problem
    • Unix Email
    • Weighted Graph
  • 3D Drawing
  • Graphviz Layout
  • Graphviz Drawing
  • Graph
  • Algorithms
  • External libraries
  • Geospatial
  • Subclass
  • Gallery
  • Drawing
  • Simple Path

Note

Go to the end to download the full example code.

Simple Path#

Draw a graph with matplotlib.

plot simple path
import matplotlib.pyplot as plt
import networkx as nx

G = nx.path_graph(8)
pos = nx.spring_layout(G, seed=47)  # Seed layout for reproducibility
nx.draw(G, pos=pos)
plt.show()

Total running time of the script: (0 minutes 0.040 seconds)

Download Jupyter notebook: plot_simple_path.ipynb

Download Python source code: plot_simple_path.py

Gallery generated by Sphinx-Gallery

© Copyright 2004-2024, NetworkX Developers.

Created using Sphinx 7.4.7.

Built with the PyData Sphinx Theme 0.15.4.