Spaces:
Runtime error
Runtime error
Commit
·
844c62c
1
Parent(s):
99aa32d
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import streamlit.components.v1 as components
|
| 3 |
+
import networkx as nx
|
| 4 |
+
import matplotlib.pyplot as plt
|
| 5 |
+
from pyvis.network import Network
|
| 6 |
+
import got
|
| 7 |
+
#Network(notebook=True)
|
| 8 |
+
st.title('Hello Pyvis')
|
| 9 |
+
# make Network show itself with repr_html
|
| 10 |
+
|
| 11 |
+
#def net_repr_html(self):
|
| 12 |
+
# nodes, edges, height, width, options = self.get_network_data()
|
| 13 |
+
# html = self.template.render(height=height, width=width, nodes=nodes, edges=edges, options=options)
|
| 14 |
+
# return html
|
| 15 |
+
|
| 16 |
+
#Network._repr_html_ = net_repr_html
|
| 17 |
+
st.sidebar.title('Choose your favorite Graph')
|
| 18 |
+
option=st.sidebar.selectbox('select graph',('Simple','Karate', 'GOT'))
|
| 19 |
+
physics=st.sidebar.checkbox('add physics interactivity?')
|
| 20 |
+
got.simple_func(physics)
|
| 21 |
+
|
| 22 |
+
if option=='Simple':
|
| 23 |
+
HtmlFile = open("test.html", 'r', encoding='utf-8')
|
| 24 |
+
source_code = HtmlFile.read()
|
| 25 |
+
components.html(source_code, height = 900,width=900)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
got.got_func(physics)
|
| 29 |
+
|
| 30 |
+
if option=='GOT':
|
| 31 |
+
HtmlFile = open("gameofthrones.html", 'r', encoding='utf-8')
|
| 32 |
+
source_code = HtmlFile.read()
|
| 33 |
+
components.html(source_code, height = 1200,width=1000)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
got.karate_func(physics)
|
| 38 |
+
|
| 39 |
+
if option=='Karate':
|
| 40 |
+
HtmlFile = open("karate.html", 'r', encoding='utf-8')
|
| 41 |
+
source_code = HtmlFile.read()
|
| 42 |
+
components.html(source_code, height = 1200,width=1000)
|