Untitled

 avatar
unknown
plain_text
5 months ago
651 B
3
Indexable
import networkx as nx
import matplotlib.pyplot as plt

# Sample Data - A list of tuples with connections (person1, person2)
linkedin_connections = [
    ("John", "Jane"),
    ("Jane", "Sarah"),
    ("John", "Alex"),
    ("Alex", "Sarah"),
    ("Jane", "Michael"),
    ("Michael", "Emily"),
]

# Create a graph object
G = nx.Graph()

# Add edges (connections) to the graph
G.add_edges_from(linkedin_connections)

# Draw the graph
plt.figure(figsize=(8, 6))
nx.draw(G, with_labels=True, node_color='skyblue', node_size=2000, edge_color='gray', font_size=10, font_weight='bold')
plt.title("LinkedIn Connections Graph")
plt.show()
Editor is loading...
Leave a Comment