====== Utilisation de GraphViz avec Python ====== * [[https://bioinfo-fr.net/python-dessine-moi-un-graphe]] ==== Installation ==== pip install graphviz ----- ==== Utilisation de base ==== import pygraphviz as pgv graph = pgv.AGraph(directed=True) graph.add_edge("A", "B", color="green", style="dashed") graph.add_edge("B", "C", color="red") graph.layout("dot") graph.draw("graph.png") graph.close() === Afficher le code correspondant === print(graph.string()) ------ ==== Créer des sous-graphes ==== graph.add_edge("A", "B", color="green", style="dashed") graph.add_edge("B", "C", color="red") graph.add_edge("C", "D") graph.add_edge("E", "D") graph.add_edge("D", "F") graph.add_subgraph(["D", "E", "F"], name="cluster_machin") # le sous-graphe doit commencer par "cluster_" pour afficher un cadre !