1
0

METADATA 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. Metadata-Version: 2.1
  2. Name: pydot
  3. Version: 1.4.2
  4. Summary: Python interface to Graphviz's Dot
  5. Home-page: https://github.com/pydot/pydot
  6. Author: Ero Carrera
  7. Author-email: ero.carrera@gmail.com
  8. Maintainer: Peter Nowee
  9. Maintainer-email: peter@peternowee.com
  10. License: MIT
  11. Project-URL: Changelog, https://github.com/pydot/pydot/blob/master/ChangeLog
  12. Project-URL: Bug Tracker, https://github.com/pydot/pydot/issues
  13. Keywords: graphviz dot graphs visualization
  14. Platform: any
  15. Classifier: Development Status :: 5 - Production/Stable
  16. Classifier: Intended Audience :: Developers
  17. Classifier: Intended Audience :: Science/Research
  18. Classifier: License :: OSI Approved :: MIT License
  19. Classifier: Natural Language :: English
  20. Classifier: Operating System :: OS Independent
  21. Classifier: Programming Language :: Python :: 2
  22. Classifier: Programming Language :: Python :: 2.7
  23. Classifier: Programming Language :: Python :: 3
  24. Classifier: Programming Language :: Python :: 3.4
  25. Classifier: Programming Language :: Python :: 3.5
  26. Classifier: Programming Language :: Python :: 3.6
  27. Classifier: Programming Language :: Python :: 3.7
  28. Classifier: Programming Language :: Python :: 3.8
  29. Classifier: Programming Language :: Python :: 3.9
  30. Classifier: Topic :: Scientific/Engineering :: Visualization
  31. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  32. Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
  33. Description-Content-Type: text/markdown
  34. Requires-Dist: pyparsing (>=2.1.4)
  35. [![Build Status](https://www.travis-ci.com/pydot/pydot.svg?branch=master)](https://www.travis-ci.com/pydot/pydot)
  36. [![PyPI](https://img.shields.io/pypi/v/pydot.svg)](https://pypi.org/project/pydot/)
  37. About
  38. =====
  39. `pydot`:
  40. - is an interface to [Graphviz][1]
  41. - can parse and dump into the [DOT language][2] used by GraphViz,
  42. - is written in pure Python,
  43. and [`networkx`][3] can convert its graphs to `pydot`.
  44. Development occurs at [GitHub][11], where you can report issues and
  45. contribute code.
  46. Examples
  47. ========
  48. The examples here will show you the most common input, editing and
  49. output methods.
  50. Input
  51. -----
  52. No matter what you want to do with `pydot`, it will need some input to
  53. start with. Here are 3 common options:
  54. 1. Import a graph from an existing DOT-file.
  55. Use this method if you already have a DOT-file describing a graph,
  56. for example as output of another program. Let's say you already
  57. have this `example.dot` (based on an [example from Wikipedia][12]):
  58. ```dot
  59. graph my_graph {
  60. bgcolor="yellow";
  61. a [label="Foo"];
  62. b [shape=circle];
  63. a -- b -- c [color=blue];
  64. }
  65. ```
  66. Just read the graph from the DOT-file:
  67. ```python
  68. import pydot
  69. graphs = pydot.graph_from_dot_file('example.dot')
  70. graph = graphs[0]
  71. ```
  72. 2. or: Parse a graph from an existing DOT-string.
  73. Use this method if you already have a DOT-string describing a
  74. graph in a Python variable:
  75. ```python
  76. import pydot
  77. dot_string = """graph my_graph {
  78. bgcolor="yellow";
  79. a [label="Foo"];
  80. b [shape=circle];
  81. a -- b -- c [color=blue];
  82. }"""
  83. graphs = pydot.graph_from_dot_data(dot_string)
  84. graph = graphs[0]
  85. ```
  86. 3. or: Create a graph from scratch using pydot objects.
  87. Now this is where the cool stuff starts. Use this method if you
  88. want to build new graphs from Python.
  89. ```python
  90. import pydot
  91. graph = pydot.Dot('my_graph', graph_type='graph', bgcolor='yellow')
  92. # Add nodes
  93. my_node = pydot.Node('a', label='Foo')
  94. graph.add_node(my_node)
  95. # Or, without using an intermediate variable:
  96. graph.add_node(pydot.Node('b', shape='circle'))
  97. # Add edges
  98. my_edge = pydot.Edge('a', 'b', color='blue')
  99. graph.add_edge(my_edge)
  100. # Or, without using an intermediate variable:
  101. graph.add_edge(pydot.Edge('b', 'c', color='blue'))
  102. ```
  103. Imagine using these basic building blocks from your Python program
  104. to dynamically generate a graph. For example, start out with a
  105. basic `pydot.Dot` graph object, then loop through your data while
  106. adding nodes and edges. Use values from your data as labels, to
  107. determine shapes, edges and so forth. This way, you can easily
  108. build visualizations of thousands of interconnected items.
  109. 4. or: Convert a NetworkX graph to a pydot graph.
  110. NetworkX has conversion methods for pydot graphs:
  111. ```python
  112. import networkx
  113. import pydot
  114. # See NetworkX documentation on how to build a NetworkX graph.
  115. graph = networkx.drawing.nx_pydot.to_pydot(my_networkx_graph)
  116. ```
  117. Edit
  118. ----
  119. You can now further manipulate your graph using pydot methods:
  120. - Add further nodes and edges:
  121. ```python
  122. graph.add_edge(pydot.Edge('b', 'd', style='dotted'))
  123. ```
  124. - Edit attributes of graph, nodes and edges:
  125. ```python
  126. graph.set_bgcolor('lightyellow')
  127. graph.get_node('b')[0].set_shape('box')
  128. ```
  129. Output
  130. ------
  131. Here are 3 different output options:
  132. 1. Generate an image.
  133. To generate an image of the graph, use one of the `create_*()` or
  134. `write_*()` methods.
  135. - If you need to further process the output in Python, the
  136. `create_*` methods will get you a Python bytes object:
  137. ```python
  138. output_graphviz_svg = graph.create_svg()
  139. ```
  140. - If instead you just want to save the image to a file, use one of
  141. the `write_*` methods:
  142. ```python
  143. graph.write_png('output.png')
  144. ```
  145. 2. Retrieve the DOT string.
  146. There are two different DOT strings you can retrieve:
  147. - The "raw" pydot DOT: This is generated the fastest and will
  148. usually still look quite similar to the DOT you put in. It is
  149. generated by pydot itself, without calling Graphviz.
  150. ```python
  151. # As a string:
  152. output_raw_dot = graph.to_string()
  153. # Or, save it as a DOT-file:
  154. graph.write_raw('output_raw.dot')
  155. ```
  156. - The Graphviz DOT: You can use it to check how Graphviz lays out
  157. the graph before it produces an image. It is generated by
  158. Graphviz.
  159. ```python
  160. # As a bytes literal:
  161. output_graphviz_dot = graph.create_dot()
  162. # Or, save it as a DOT-file:
  163. graph.write_dot('output_graphviz.dot')
  164. ```
  165. 3. Convert to a NetworkX graph.
  166. Here as well, NetworkX has a conversion method for pydot graphs:
  167. ```python
  168. my_networkx_graph = networkx.drawing.nx_pydot.from_pydot(graph)
  169. ```
  170. More help
  171. ---------
  172. For more help, see the docstrings of the various pydot objects and
  173. methods. For example, `help(pydot)`, `help(pydot.Graph)` and
  174. `help(pydot.Dot.write)`.
  175. More [documentation contributions welcome][13].
  176. Installation
  177. ============
  178. From [PyPI][4] using [`pip`][5]:
  179. `pip install pydot`
  180. From source:
  181. `python setup.py install`
  182. Dependencies
  183. ============
  184. - [`pyparsing`][6]: used only for *loading* DOT files,
  185. installed automatically during `pydot` installation.
  186. - GraphViz: used to render graphs as PDF, PNG, SVG, etc.
  187. Should be installed separately, using your system's
  188. [package manager][7], something similar (e.g., [MacPorts][8]),
  189. or from [its source][9].
  190. License
  191. =======
  192. Distributed under an [MIT license][10].
  193. Contacts
  194. ========
  195. Maintainers:
  196. - Sebastian Kalinowski <sebastian@kalinowski.eu> (GitHub: @prmtl)
  197. - Peter Nowee <peter@peternowee.com> (GitHub: @peternowee)
  198. Original author: Ero Carrera <ero.carrera@gmail.com>
  199. [1]: https://www.graphviz.org
  200. [2]: https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29
  201. [3]: https://github.com/networkx/networkx
  202. [4]: https://pypi.python.org/pypi
  203. [5]: https://github.com/pypa/pip
  204. [6]: https://github.com/pyparsing/pyparsing
  205. [7]: https://en.wikipedia.org/wiki/Package_manager
  206. [8]: https://www.macports.org
  207. [9]: https://gitlab.com/graphviz/graphviz
  208. [10]: https://github.com/pydot/pydot/blob/master/LICENSE
  209. [11]: https://github.com/pydot/pydot
  210. [12]: https://en.wikipedia.org/w/index.php?title=DOT_(graph_description_language)&oldid=1003001464#Attributes
  211. [13]: https://github.com/pydot/pydot/issues/130