55import pathlib
66
77from neo4j_viz .pandas import from_dfs
8- from neo4j_viz import VisualizationGraph
8+ from neo4j_viz import VisualizationGraph , Layout
99
1010# Path to this file
1111script_path = pathlib .Path (__file__ ).resolve ()
@@ -32,9 +32,9 @@ def create_visualization_graph() -> VisualizationGraph:
3232
3333@st .cache_data
3434def render_graph (
35- _VG : VisualizationGraph , height : int , initial_zoom : float = 0.1
35+ _VG : VisualizationGraph , height : int , layout : Layout , initial_zoom : float = 0.1
3636) -> HTML :
37- return VG .render (initial_zoom = initial_zoom , height = f"{ height } px" )
37+ return VG .render (initial_zoom = initial_zoom , height = f"{ height } px" , layout = layout )
3838
3939
4040VG = create_visualization_graph ()
@@ -47,6 +47,10 @@ def render_graph(
4747
4848with st .sidebar :
4949 height = st .slider ("Height in pixels" , 100 , 2000 , 600 , 50 )
50+ layout = st .radio (
51+ "Layout" ,
52+ [Layout .FORCE_DIRECTED , Layout .HIERARCHICAL , Layout .GRID ],
53+ )
5054 show_code = st .checkbox ("Show code" )
5155
5256st .header ("Visualization" )
@@ -56,7 +60,7 @@ def render_graph(
5660)
5761
5862components .html (
59- render_graph (VG , height = height ).data ,
63+ render_graph (VG , height = height , layout = layout ).data ,
6064 height = height ,
6165)
6266
0 commit comments