Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,10 @@ import streamlit as st
|
|
| 2 |
import matplotlib.pyplot as plt
|
| 3 |
import networkx as nx
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# Sidebar for selecting an option
|
| 6 |
sidebar_option = st.sidebar.radio("Select an option",
|
| 7 |
["Select an option", "Basic: Properties",
|
|
@@ -161,7 +165,7 @@ elif sidebar_option == "Basic: Simple graph":
|
|
| 161 |
display_simple_graph(G, pos)
|
| 162 |
|
| 163 |
# Default example: directed graph with custom positions (added the missing part)
|
| 164 |
-
if option == "Default Example" and st.session_state.graph_displayed
|
| 165 |
G = nx.DiGraph([(0, 3), (1, 3), (2, 4), (3, 5), (3, 6), (4, 6), (5, 6)])
|
| 166 |
|
| 167 |
# Group nodes by column
|
|
|
|
| 2 |
import matplotlib.pyplot as plt
|
| 3 |
import networkx as nx
|
| 4 |
|
| 5 |
+
# Initialize session state variable if it does not exist
|
| 6 |
+
if 'graph_displayed' not in st.session_state:
|
| 7 |
+
st.session_state.graph_displayed = False
|
| 8 |
+
|
| 9 |
# Sidebar for selecting an option
|
| 10 |
sidebar_option = st.sidebar.radio("Select an option",
|
| 11 |
["Select an option", "Basic: Properties",
|
|
|
|
| 165 |
display_simple_graph(G, pos)
|
| 166 |
|
| 167 |
# Default example: directed graph with custom positions (added the missing part)
|
| 168 |
+
if option == "Default Example" and not st.session_state.graph_displayed:
|
| 169 |
G = nx.DiGraph([(0, 3), (1, 3), (2, 4), (3, 5), (3, 6), (4, 6), (5, 6)])
|
| 170 |
|
| 171 |
# Group nodes by column
|