Skip to content

Commit

Permalink
added scenarioconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
satyyam11 committed Oct 13, 2024
1 parent 010477a commit 4d56421
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 17 deletions.
46 changes: 46 additions & 0 deletions taipy/common/config/ScenarioConfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import matplotlib.pyplot as plt
import networkx as nx


class ScenarioConfig:
def __init__(self):
self.graph = nx.DiGraph() # Create a directed graph

def add_node(self, node):
"""Add a node to the graph."""
self.graph.add_node(node)

def add_edge(self, from_node, to_node):
"""Add an edge between two nodes."""
self.graph.add_edge(from_node, to_node)

def export_graph_as_image(self, file_path):
"""Export the graph as an image."""
plt.figure(figsize=(10, 6))
pos = nx.spring_layout(self.graph) # Positioning the nodes
nx.draw(self.graph, pos, with_labels=True, node_size=3000, node_color='lightblue', font_size=10,
font_weight='bold')

# Save the graph as an image
plt.savefig(file_path)
plt.close() # Close the plot to avoid display
print(f"Graph exported as image: {file_path}")


if __name__ == "__main__":
config = ScenarioConfig()

# Add vertices (nodes)
config.add_node("Node1")
config.add_node("Node2")
config.add_node("Node3")
config.add_node("Node4")

# Add edges (connections)
config.add_edge("Node1", "Node2")
config.add_edge("Node1", "Node3")
config.add_edge("Node2", "Node4")
config.add_edge("Node3", "Node4")

# Export the graph as an image
config.export_graph_as_image("scenario_graph.png")
17 changes: 0 additions & 17 deletions taipy/common/config/graph_visualizer.py

This file was deleted.

Binary file added taipy/common/config/scenario_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added taipy/common/config/scenario_grph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4d56421

Please sign in to comment.