-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimepass.py
46 lines (37 loc) · 1.17 KB
/
timepass.py
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
35
36
37
38
39
40
41
42
43
44
45
46
import streamlit as st
import graphviz
st.title('Welcome to Graph Visualization\n')
st.header('Check if your graph is unidirectional or bidirectional')
type = st.radio('Enter the type of your graph',('Unidirectional','Bidirectional'))
bidirectional = False
unidirectional = False
if(type == 'Bidirectional'):
bidirectional = True
else:
unidirectional = True
st.header('Enter the edges in format a -> b form.')
text = st.text_input('Input Here')
text = str(text)
text = text.strip()
relation = text.split(' ')
if len(text)>0:
if bidirectional:
graph = graphviz.Graph()
for x in relation:
a_b = x.split('->')
try:
graph.edge(a_b[0],a_b[1])
except:
st.warning('Enter in the correct format')
st.stop()
st.graphviz_chart(graph)
else:
graph = graphviz.Digraph()
for x in relation:
a_b = x.split('->')
try:
graph.edge(a_b[0],a_b[1])
except:
st.warning('Enter in the correct format')
st.stop()
st.graphviz_chart(graph)