awacke1's picture
Create app.py
f96c606 verified
raw
history blame contribute delete
509 Bytes
import streamlit as st
from pyvis.network import Network
import networkx as nx
import tempfile
# Create a graph
G = nx.fast_gnp_random_graph(n=10, p=0.2)
# Convert NetworkX graph to PyVis graph
nt = Network("500px", "500px", notebook=True)
nt.from_nx(G)
# Generate the graph to an HTML file
tmp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.html')
nt.save_graph(tmp_file.name)
# Use Streamlit components to display the graph
st.components.v1.html(tmp_file.read(), height=500, scrolling=False)