File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -36,13 +36,15 @@ def _split_prefix(s: str, max_chars: int = 50) -> str:
3636
3737def render_graphviz (
3838 documents : Iterable [Document ],
39+ engine : Optional [str ] = None ,
3940 node_color : Optional [str ] = None ,
4041 node_colors : Optional [Dict [str , Optional [str ]]] = {},
4142) -> "graphviz.Digraph" :
4243 """Render a collection of GraphVectorStore documents to GraphViz format.
4344
4445 Args:
4546 documents: The documents to render.
47+ engine: GraphViz layout engine to use. `None` uses the default.
4648 node_color: General node color. Defaults to `white`.
4749 node_colors: Dictionary specifying colors of specific nodes. Useful for
4850 emphasizing nodes that were selected by MMR, or differ from other
@@ -78,7 +80,7 @@ def render_graphviz(
7880
7981 tags = set ()
8082
81- graph = graphviz .Digraph ()
83+ graph = graphviz .Digraph (engine = engine )
8284 graph .attr (rankdir = "LR" )
8385 graph .attr ("node" , style = "filled" )
8486 for document in documents :
Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ def test_visualize_simple_graph():
4949 "}\n "
5050 )
5151
52+ assert render_graphviz ([doc1 , doc2 ], engine = "fdp" ).engine == "fdp"
53+
5254 assert render_graphviz ([doc1 , doc2 ], node_colors = {"a" : "gold" }).source == (
5355 "digraph {\n "
5456 "\t rankdir=LR\n "
You can’t perform that action at this time.
0 commit comments