Simple Diagram (Visual)

import matplotlib.pyplot as plt
import networkx as nx

# Create a simple network diagram
G = nx.DiGraph()

# Add nodes
nodes = [“PC”, “Laptop”, “Printer”, “Switch”, “Router”, “Internet”]
G.add_nodes_from(nodes)

# Add edges to represent connections
edges = [
(“PC”, “Switch”),
(“Laptop”, “Switch”),
(“Printer”, “Switch”),
(“Switch”, “Router”),
(“Router”, “Internet”)
]
G.add_edges_from(edges)

# Position nodes manually for clarity
pos = {
“PC”: (-1, 0),
“Laptop”: (-1, -1),
“Printer”: (-1, 1),
“Switch”: (0.5, 0),
“Router”: (2, 0),
“Internet”: (3.5, 0)
}

# Draw the diagram
plt.figure(figsize=(8, 5))
nx.draw(
G, pos, with_labels=True, node_size=2500,
node_color=”lightblue”, font_size=10, font_weight=”bold”,
arrows=True, arrowsize=15, edgecolors=”black”
)

plt.title(“Basic Computer Network Diagram”, fontsize=14, fontweight=”bold”)
plt.show()

Leave a Reply

Your email address will not be published. Required fields are marked *