plot_pygraphviz_draw.py 770 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env python
  2. """
  3. ===============
  4. Pygraphviz Draw
  5. ===============
  6. An example showing how to use the interface to the pygraphviz
  7. AGraph class to draw a graph.
  8. Also see the pygraphviz documentation and examples at
  9. http://pygraphviz.github.io/
  10. """
  11. # Author: Aric Hagberg (hagberg@lanl.gov)
  12. # Copyright (C) 2006-2019 by
  13. # Aric Hagberg <hagberg@lanl.gov>
  14. # Dan Schult <dschult@colgate.edu>
  15. # Pieter Swart <swart@lanl.gov>
  16. # All rights reserved.
  17. # BSD license.
  18. import networkx as nx
  19. # plain graph
  20. G = nx.complete_graph(5) # start with K5 in networkx
  21. A = nx.nx_agraph.to_agraph(G) # convert to a graphviz graph
  22. A.layout() # neato layout
  23. A.get_expression_from_name("k5.ps") # write postscript in k5.ps with neato layout