dipsmom commited on
Commit
94d6bf2
·
verified ·
1 Parent(s): 9f80db1

Create graph_generator.py – Graph Logic

Browse files
Files changed (1) hide show
  1. graph_generator.py – Graph Logic +57 -0
graph_generator.py – Graph Logic ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import matplotlib.pyplot as plt
2
+ import networkx as nx
3
+
4
+ # Pre-defined symbolic relationships
5
+ symbolic_relationships = {
6
+ "Black Hole": ["Destruction", "Wormhole"],
7
+ "Wormhole": ["Singularity"],
8
+ "Singularity": ["White Hole", "Cosmic Balance"],
9
+ "White Hole": ["Creation", "New Universe"],
10
+ "Vibration": ["Singularity", "Cosmic Balance"],
11
+ "Moon": ["Tranquility", "Time Cycles"],
12
+ "Sun": ["Energy", "Cosmic Balance"],
13
+ "Ashes": ["Purification", "Renunciation"],
14
+ "Snake Garland": ["Immortality", "Time"],
15
+ "108": ["Cosmic Distances", "Spiritual Significance"],
16
+ "Trimurti": ["Creation", "Sustenance", "Destruction"]
17
+ }
18
+
19
+ # Extract symbols from user input
20
+ def extract_symbols(user_input):
21
+ return [word for word in symbolic_relationships.keys() if word in user_input]
22
+
23
+ # Generate Damru-shaped graph
24
+ def generate_damru_graph(user_input, output_path):
25
+ symbols = extract_symbols(user_input)
26
+
27
+ if not symbols:
28
+ return "No symbols found"
29
+
30
+ edges = []
31
+ for symbol in symbols:
32
+ for connected in symbolic_relationships.get(symbol, []):
33
+ edges.append((symbol, connected))
34
+
35
+ # Define positions for the graph
36
+ pos = {
37
+ "Black Hole": (-3, 3), "Destruction": (-2, 2), "Wormhole": (-1, 1),
38
+ "Singularity": (0, 0), "Cosmic Balance": (0, -2), "White Hole": (3, 3),
39
+ "Creation": (2, 2), "New Universe": (3, 5),
40
+ "Vibration": (0, -1), "Moon": (-2, -1), "Sun": (2, -1),
41
+ "Ashes": (-2, -3), "Snake Garland": (2, -3), "108": (0, 2),
42
+ "Trimurti": (0, -4)
43
+ }
44
+
45
+ G = nx.DiGraph()
46
+ G.add_edges_from(edges)
47
+
48
+ # Plot and save the graph
49
+ plt.figure(figsize=(10, 8))
50
+ nx.draw_networkx_nodes(G, pos, node_size=3000, node_color="lightblue", edgecolors="black")
51
+ nx.draw_networkx_edges(G, pos, edge_color="gray", arrowsize=12, arrowstyle='-|>')
52
+ nx.draw_networkx_labels(G, pos, font_size=10, font_color="black", font_weight="bold")
53
+ plt.title("Damru-Shaped Graph of Cosmic Relationships", fontsize=14, color="purple", fontweight="bold")
54
+ plt.axis("off")
55
+ plt.savefig(output_path)
56
+ plt.close()
57
+ return "Graph generated successfully"