Spaces:
Runtime error
Runtime error
File size: 949 Bytes
231b6fa 9c710c0 231b6fa 5b4c973 9c710c0 231b6fa 9c710c0 231b6fa 9c710c0 231b6fa 9c710c0 231b6fa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import networkx as nx
from pyvis import Network
class ImportsGraphVisualizer:
@classmethod
def visualize(
cls,
imports_graph: nx.Graph,
directed: bool = True,
layout: bool = True, # Use hierarchical if True
neighborhood_highlight: bool = True,
select_menu: bool = True,
width: int = 100,
height: int = 800,
show_buttons: bool = False,
display_html_name: str = "nx.html",
):
_pyvis_network = Network(
width=f"{width}%",
height=f"{height}px",
directed=directed,
layout=layout,
neighborhood_highlight=neighborhood_highlight,
select_menu=select_menu,
)
_pyvis_network.toggle_hide_edges_on_drag(True)
_pyvis_network.from_nx(imports_graph)
if show_buttons:
_pyvis_network.show_buttons()
_pyvis_network.show(display_html_name)
|