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 ()
@@ -37,9 +37,9 @@ def create_visualization_graph() -> VisualizationGraph:
3737
3838@st .cache_data
3939def render_graph (
40- _VG : VisualizationGraph , height : int , initial_zoom : float = 0.1
40+ _VG : VisualizationGraph , height : int , layout : Layout , initial_zoom : float = 0.1
4141) -> HTML :
42- return VG .render (initial_zoom = initial_zoom , height = f"{ height } px" )
42+ return VG .render (initial_zoom = initial_zoom , height = f"{ height } px" , layout = layout )
4343
4444
4545VG = create_visualization_graph ()
@@ -52,6 +52,10 @@ def render_graph(
5252
5353with st .sidebar :
5454 height = st .slider ("Height in pixels" , 100 , 2000 , 600 , 50 )
55+ layout = st .radio (
56+ "Layout" ,
57+ [Layout .FORCE_DIRECTED , Layout .HIERARCHICAL , Layout .GRID ],
58+ )
5559 show_code = st .checkbox ("Show code" )
5660
5761st .header ("Visualization" )
@@ -61,7 +65,7 @@ def render_graph(
6165)
6266
6367components .html (
64- render_graph (VG , height = height ).data ,
68+ render_graph (VG , height = height , layout = layout ).data ,
6569 height = height ,
6670)
6771
0 commit comments