Logo image Logo image
  • Install
  • Tutorial
  • Reference
  • Releases
  • Developer
  • Gallery
  • Guides
    • devel (latest)
    • current (stable)
  • Properties
  • Read and write graphs.
  • Simple graph
  • 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
  • Mayavi2
  • Basic matplotlib
  • Atlas
  • Circular Tree
  • Decomposition
  • Giant Component
  • Lanl Routes
  • Attributes
  • Conversion
  • 2D Grid
  • Atlas
  • Degree Sequence
  • Erdos Renyi
  • Expected Degree Sequence
  • Football
  • Karate Club
  • Morse Trie
  • Napoleon Russian Campaign
  • Roget
  • Words/Ladder Graph
  • Beam Search
  • Betweeness Centrality
  • Blockmodel
  • Circuits
  • Davis Club
  • Dedensification
  • Iterated Dynamical Systems
  • Krackhardt Centrality
  • Parallel Betweenness
  • Reverse Cuthill–McKee
  • SNAP Graph Summary
  • Subgraphs
  • Javascript
  • igraph
  • Delaunay graphs from geographic points
  • Graphs from a set of lines
  • OpenStreetMap with OSMnx
  • Graphs from geographic points
  • Graphs from Polygons
  • Antigraph
  • Print Graph

Note

Click here 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.064 seconds)

Download Python source code: plot_simple_path.py

Download Jupyter notebook: plot_simple_path.ipynb

Gallery generated by Sphinx-Gallery

© Copyright 2004-2022, NetworkX Developers.

Created using Sphinx 5.0.2.