| Name | Type | Description |
|---|---|---|
layout | Optional[Callable] | Default: None
|
nx_opts | Optional[dict] | Default: NoneKeyword arguments for to_networkx function. |
json_opts | Optional[dict] | Default: None |
edge_opts | Optional[dict] | Default: None |
node_opts | Optional[dict] | Default: None |
**kwargs | Any | Default: {} |
Draws a Knowledge Graph as Holoviews/Bokeh interactive plot.
We first convert the entity collection to a NetworkX Graph, and then convert it to a Holoviews Graph via their API.
The default layout chosen is the spring_layout.
This maximizes the distance between nodes. As our entities have a type field,
however, another good layout choice might be
layout=nx.multipartite_layout, nx_opts["subset_key"]= "type"
as multipartite layout positions nodes in straight lines by subset key.
NOTE: Requires optional-dependency "viz", i.e. pip install "langchain-mongodb[viz]".
You can save the view as any HoloViews object with .save.
The type will be inferred from the filename's suffix,
(e.g., hv.save(graph, "graph.html")) or by clicking the download widget
on the Bokeh plot from a Jupyter notebook.
Returns: holoviews.Graph <https://holoviews.org/user_guide/Network_Graphs.html>_
Keyword arguments for printing of node attributes and types.
Keyword arguments to draw edges.
Keyword arguments to draw nodes.
Keyword arguments available for compatibility.