eaglelandsonce commited on
Commit
5b25129
1 Parent(s): 8e5029d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -26
app.py CHANGED
@@ -127,40 +127,22 @@ def main():
127
 
128
 
129
 
130
-
131
  if sensors: # Check if there are sensors to display
132
  st.header("Building Sensor Network")
133
- sensor_store = TripleStore()
134
  building_name = f"{data['buildings'][selected_index]['type']} ({selected_building_coords[0]}, {selected_building_coords[1]})"
135
 
136
- # Create a central node for the building
137
- central_node_color = "#FFD700" # Gold color for the central node (building)
138
- sensor_store.add_node(Node(id=building_name, label=building_name, color=central_node_color, size=400))
139
-
140
- # Define a color for sensor nodes
141
- sensor_node_color = "#90EE90" # Light green for sensor nodes
142
-
143
- # Create nodes for each sensor and link them to the central building node
144
  for sensor in sensors:
145
- sensor_id = f"{sensor}-{selected_building_coords}" # Ensuring uniqueness
146
- sensor_label = f"Sensor: {sensor}" # Label for the sensor nodes
147
-
148
- # Add sensor node to the store
149
- sensor_store.add_node(Node(id=sensor_id, label=sensor_label, color=sensor_node_color, size=300))
150
-
151
- # Connect each sensor node to the central building node
152
- sensor_store.add_edge(Edge(source=building_name, target=sensor_id, label=""))
153
 
154
  # Configuration for the graph visualization
155
- agraph_config = Config(height=600, width=600, nodeHighlightBehavior=True, highlightColor="#F7A7A6", directed=True, collapsible=True, node={'labelProperty':'label'})
156
-
157
- # Display the graph
158
- agraph(nodes=list(sensor_store.getNodes()), edges=list(sensor_store.getEdges()), config=agraph_config)
159
-
160
-
161
-
162
-
163
 
 
 
164
 
165
  """
166
 
 
127
 
128
 
129
 
 
130
  if sensors: # Check if there are sensors to display
131
  st.header("Building Sensor Network")
132
+ graph_store = TripleStore()
133
  building_name = f"{data['buildings'][selected_index]['type']} ({selected_building_coords[0]}, {selected_building_coords[1]})"
134
 
135
+ # Central node for the building - adding as both subject and object to ensure it appears in the graph
 
 
 
 
 
 
 
136
  for sensor in sensors:
137
+ sensor_id = f"Sensor: {sensor}" # Label for sensor nodes
138
+ # Add triple: each sensor node is connected to the central building node
139
+ graph_store.add_triple(subject=building_name, predicate="has_sensor", object=sensor_id)
 
 
 
 
 
140
 
141
  # Configuration for the graph visualization
142
+ agraph_config = Config(height=600, width=600, nodeHighlightBehavior=True, highlightColor="#F7A7A6", directed=True, collapsible=True)
 
 
 
 
 
 
 
143
 
144
+ # Display the graph
145
+ agraph(nodes=list(graph_store.getNodes()), edges=list(graph_store.getEdges()), config=agraph_config)
146
 
147
  """
148