Текст примера набран из
https://habr.com/ru/companies/skillfactory/articles/721838/ # Fron https://habr.com/ru/companies/skillfactory/articles/721838/
import os
import networkx as nx
G = nx.Graph()
print(G)
# Graph with 0 nodes and 0 edges
G.add_node("Singapore")
G.add_node("San Francisco")
G.add_node("Tokyo")
print(G)
# Graph with 3 nodes and 0 edges
G.add_nodes_from(["Riga", "Copenhagen"])pip
print(G)
# Graph with 5 nodes and 0 edges
G.add_edge("Singapore","San Francisco")
G.add_edge("San Francisco","Tokyo")
G.add_edges_from(
[
("Riga","Copenhagen"),
("Copenhagen","Singapore"),
("Singapore","Tokyo"),
("Riga","San Francisco"),
("San Francisco","Singapore"),
]
)
print(G)
# Graph with 5 nodes and 6 edges
nx.draw(G)
os.system("pause")
Выполнение по cmd проходит без замечаний, но изображение не видно. Антивирус снят.