def path_graph(nodes): graph = AGraph(directed=True) for node in nodes: graph.add_node(node, shape='rectangle') graph.add_path(nodes) return graph