import pydotplus import matplotlib.pyplot as plt import matplotlib.image as mpimg style = { "bgcolor" : "#6b85d1", "fgcolor" : "#FFFFFF" } def display_BN ( node_names, bn_struct, bn_name, style ): graph = pydot.Dot( bn_name, graph_type='digraph') # création des noeuds du réseau for name in node_names: new_node = pydot.Node( name, style="filled", fillcolor=style["bgcolor"], fontcolor=style["fgcolor"] ) graph.add_node( new_node ) # création des arcs for node in range ( len ( node_names ) ): parents = bn_struct[node] for par in parents: new_edge = pydot.Edge ( node_names[par], node_names[node] ) graph.add_edge ( new_edge ) # sauvegarde et affaichage outfile = bn_name + '.png' graph.write_png( outfile ) img = mpimg.imread ( outfile ) plt.imshow( img )