Skip to content

Instantly share code, notes, and snippets.

@RobertTalbert
Created November 26, 2024 15:56
Show Gist options
  • Save RobertTalbert/7d91acc8a35156d11fc55343eb7d65dd to your computer and use it in GitHub Desktop.
Save RobertTalbert/7d91acc8a35156d11fc55343eb7d65dd to your computer and use it in GitHub Desktop.
# Load libraries
import networkx as nx
import matplotlib.pyplot as plt
# Generate the graph
## The second parameter is a probability that two distinct vertices are adjacent
## Raise the probability for more connections
g = nx.gnp_random_graph(8, 0.5)
# Draw the graph
nx.draw(g, pos=nx.circular_layout(g), with_labels=True, node_color='lightgray')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment