2.2 KiB
2.2 KiB
In [ ]:
# Installation (si nécessaire) — peut être ignorée si networkx est déjà présent
# %pip install networkx matplotlib
import networkx as nx
import matplotlib.pyplot as pltIn [ ]:
# TODO: Compléter la liste d'arêtes pour former votre mini-réseau social
G = nx.Graph()
G.add_edges_from([
("Alice", "Bob"),
("Bob", "Claire"),
("Alice", "David"),
# ("Claire", "David"), # décommentez pour ajouter un lien
])
print("Nœuds :", list(G.nodes()))
print("Arêtes:", list(G.edges()))
print("Degrés:", dict(G.degree()))
plt.figure()
nx.draw(G, with_labels=True)
plt.show()