langchain_core.runnables.graph_draw.draw¶

langchain_core.runnables.graph_draw.draw(vertices: Mapping[str, str], edges: Sequence[Tuple[str, str]]) str[source]¶

Build a DAG and draw it in ASCII.

Parameters
  • vertices (list) – list of graph vertices.

  • edges (list) – list of graph edges.

Returns

ASCII representation

Return type

str

Example

>>> from dvc.dagascii import draw
>>> vertices = [1, 2, 3, 4]
>>> edges = [(1, 2), (2, 3), (2, 4), (1, 4)]
>>> print(draw(vertices, edges))
+---+     +---+
| 3 |     | 4 |
+---+    *+---+
  *    **   *
  *  **     *
  * *       *
+---+       *
| 2 |      *
+---+     *
     *    *
      *  *
       **
     +---+
     | 1 |
     +---+