juneja-codebase 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. juneja_codebase/__init__.py +6 -0
  2. juneja_codebase/main.py +197 -0
  3. juneja_codebase/templates/compiler_design/AnshJuneja_Practical10_CD.l +15 -0
  4. juneja_codebase/templates/compiler_design/AnshJuneja_Practical10_CD.y +27 -0
  5. juneja_codebase/templates/compiler_design/AnshJuneja_Practical11_CD.l +15 -0
  6. juneja_codebase/templates/compiler_design/AnshJuneja_Practical11_CD.y +36 -0
  7. juneja_codebase/templates/compiler_design/AnshJuneja_Practical12_CD.l +14 -0
  8. juneja_codebase/templates/compiler_design/AnshJuneja_Practical12_CD.y +31 -0
  9. juneja_codebase/templates/compiler_design/AnshJuneja_Practical13_CD.l +14 -0
  10. juneja_codebase/templates/compiler_design/AnshJuneja_Practical13_CD.y +38 -0
  11. juneja_codebase/templates/compiler_design/AnshJuneja_Practical1_CD.l +38 -0
  12. juneja_codebase/templates/compiler_design/AnshJuneja_Practical2_CD.l +27 -0
  13. juneja_codebase/templates/compiler_design/AnshJuneja_Practical3_CD.l +39 -0
  14. juneja_codebase/templates/compiler_design/AnshJuneja_Practical4_CD.l +32 -0
  15. juneja_codebase/templates/compiler_design/AnshJuneja_Practical5_CD.l +51 -0
  16. juneja_codebase/templates/compiler_design/AnshJuneja_Practical6_CD.l +46 -0
  17. juneja_codebase/templates/compiler_design/AnshJuneja_Practical7_CD.l +36 -0
  18. juneja_codebase/templates/compiler_design/AnshJuneja_Practical8_CD.l +33 -0
  19. juneja_codebase/templates/compiler_design/AnshJuneja_Practical9_CD.l +19 -0
  20. juneja_codebase/templates/compiler_design/AnshJuneja_Practical9_CD.y +36 -0
  21. juneja_codebase/templates/social_network_analysis/1_try.ipynb +286 -0
  22. juneja_codebase/templates/social_network_analysis/2_try.ipynb +352 -0
  23. juneja_codebase/templates/social_network_analysis/3_try.ipynb +207 -0
  24. juneja_codebase/templates/social_network_analysis/4_try.ipynb +1218 -0
  25. juneja_codebase/templates/social_network_analysis/5_try.ipynb +326 -0
  26. juneja_codebase/templates/social_network_analysis/6_try.ipynb +241 -0
  27. juneja_codebase/templates/social_network_analysis/new.ipynb +592 -0
  28. juneja_codebase-0.1.3.dist-info/LICENSE +21 -0
  29. juneja_codebase-0.1.3.dist-info/METADATA +75 -0
  30. juneja_codebase-0.1.3.dist-info/RECORD +33 -0
  31. juneja_codebase-0.1.3.dist-info/WHEEL +5 -0
  32. juneja_codebase-0.1.3.dist-info/entry_points.txt +3 -0
  33. juneja_codebase-0.1.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,33 @@
1
+ %{
2
+ #include <stdio.h>
3
+
4
+ int valid = 1;
5
+ %}
6
+
7
+ %%
8
+
9
+ [0-9]+ { /* valid number */ }
10
+
11
+ [+\-*/] { /* operator */ }
12
+
13
+ [() ] { /* parentheses or space */ }
14
+
15
+ \n { return 0; }
16
+
17
+ . { valid = 0; }
18
+
19
+ %%
20
+
21
+ int yywrap() { return 1; }
22
+
23
+ int main() {
24
+ printf("Enter expression: ");
25
+ yylex();
26
+
27
+ if (valid)
28
+ printf("Valid expression\n");
29
+ else
30
+ printf("Invalid expression\n");
31
+
32
+ return 0;
33
+ }
@@ -0,0 +1,19 @@
1
+ %{
2
+ #include "y.tab.h"
3
+ %}
4
+
5
+ %%
6
+
7
+ [0-9]+ { return NUM; }
8
+
9
+ [+\-*/()] { return yytext[0]; }
10
+
11
+ [ \t] { /* ignore spaces */ }
12
+
13
+ \n { return '\n'; }
14
+
15
+ . { return yytext[0]; }
16
+
17
+ %%
18
+
19
+ int yywrap() { return 1; }
@@ -0,0 +1,36 @@
1
+ %{
2
+ #include <stdio.h>
3
+ #include <stdlib.h>
4
+
5
+ int yylex();
6
+ int yyerror(const char *s);
7
+ %}
8
+
9
+ %token NUM
10
+
11
+ %%
12
+
13
+ S : E '\n' { printf("Valid expression\n"); }
14
+ ;
15
+
16
+ E : E '+' E
17
+ | E '-' E
18
+ | E '*' E
19
+ | E '/' E
20
+ | '(' E ')'
21
+ | NUM
22
+ ;
23
+
24
+ %%
25
+
26
+ int yyerror(const char *s)
27
+ {
28
+ printf("Invalid expression\n");
29
+ return 0;
30
+ }
31
+
32
+ int main() {
33
+ printf("Enter expression:\n");
34
+ yyparse();
35
+ return 0;
36
+ }
@@ -0,0 +1,286 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "996e0e73",
6
+ "metadata": {},
7
+ "source": [
8
+ "# **Q1(A) DIRECTED GRAPH BASED ON IN & OUT DEGREE**"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "code",
13
+ "execution_count": null,
14
+ "id": "dd72f236",
15
+ "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "import networkx as nx\n",
19
+ "import matplotlib.pyplot as plt\n",
20
+ "\n",
21
+ "G = nx.DiGraph()\n",
22
+ "G.add_nodes_from([1, 2, 3, 4, 5])\n",
23
+ "\n",
24
+ "G.add_edge(1, 2, weight=4)\n",
25
+ "G.add_edge(2, 3, weight=2)\n",
26
+ "G.add_edge(3, 4, weight=7)\n",
27
+ "G.add_edge(5, 1, weight=5)\n",
28
+ "G.add_edge(2, 5, weight=2)\n",
29
+ "G.add_edge(3, 1, weight=6)\n",
30
+ "G.add_edge(4, 1, weight=8)\n",
31
+ "G.add_edge(5, 3, weight=3)\n",
32
+ "\n",
33
+ "print(\"Nodes:\", list(G.nodes()))\n",
34
+ "print(\"Edges:\", list(G.edges()))\n",
35
+ "print(\"Edges with data:\", list(G.edges(data=True)))\n",
36
+ "\n",
37
+ "degree_type = input(\"Choose degree type (in-degree(1) or out-degree(2)): \").strip()\n",
38
+ "\n",
39
+ "if degree_type == '1':\n",
40
+ " degree_dict = dict(G.in_degree())\n",
41
+ " print(\"In-Degrees:\", degree_dict)\n",
42
+ "elif degree_type == '2':\n",
43
+ " degree_dict = dict(G.out_degree())\n",
44
+ " print(\"Out-Degrees:\", degree_dict)\n",
45
+ "else:\n",
46
+ " print(\"Invalid input, defaulting to in-degree.\")\n",
47
+ " degree_dict = dict(G.in_degree())\n",
48
+ " print(\"In-Degrees:\", degree_dict)\n",
49
+ "\n",
50
+ "node_sizes = [degree_dict[n] * 700 for n in G.nodes()]\n",
51
+ "print(\"Node Sizes:\", node_sizes)\n",
52
+ "\n",
53
+ "edge_weights = [G[u][v]['weight'] for u, v in G.edges()]\n",
54
+ "edge_widths = [w * 0.5 for w in edge_weights]\n",
55
+ "print(\"Edge Weights:\", edge_weights)\n",
56
+ "\n",
57
+ "total_deg = dict(G.degree())\n",
58
+ "print(\"Total Degrees:\", total_deg)\n",
59
+ "\n",
60
+ "# Different layouts\n",
61
+ "pos = nx.kamada_kawai_layout(G, weight='weight')\n",
62
+ "#pos = nx.spring_layout(G, weight='weight', seed=42)\n",
63
+ "#pos = nx.circular_layout(G)\n",
64
+ "\n",
65
+ "plt.figure(figsize=(8, 6))\n",
66
+ "nx.draw(G, pos, with_labels=True,\n",
67
+ " node_color='pink', edge_color='blue',\n",
68
+ " node_size=node_sizes, width=edge_widths,\n",
69
+ " arrows=True)\n",
70
+ "\n",
71
+ "edge_labels = nx.get_edge_attributes(G, 'weight')\n",
72
+ "nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels)\n",
73
+ "\n",
74
+ "plt.title(\"Directed Weighted Graph\\n(Node size ~ Degree, Edge width ~ Weight, Edge length ~ Weight (Kamada–Kawai Layout))\")\n",
75
+ "plt.axis('off')\n",
76
+ "plt.show()\n"
77
+ ]
78
+ },
79
+ {
80
+ "cell_type": "markdown",
81
+ "id": "c91c2096",
82
+ "metadata": {},
83
+ "source": [
84
+ "# **Q1(B) UNDIRECTED GRAPH BASED ON TOTAL DEGREE**"
85
+ ]
86
+ },
87
+ {
88
+ "cell_type": "code",
89
+ "execution_count": null,
90
+ "id": "18eae56c",
91
+ "metadata": {},
92
+ "outputs": [],
93
+ "source": [
94
+ "# Q1(B) UNDIRECTED GRAPH BASED ON TOTAL DEGREE\n",
95
+ "# Node size ∝ total degree\n",
96
+ "# Edge width ∝ weight\n",
97
+ "# Edge length ∝ weight (using Kamada–Kawai layout)\n",
98
+ "\n",
99
+ "import networkx as nx\n",
100
+ "import matplotlib.pyplot as plt\n",
101
+ "\n",
102
+ "G = nx.Graph()\n",
103
+ "\n",
104
+ "G.add_nodes_from([1, 2, 3, 4, 5])\n",
105
+ "print(\"Nodes:\", G.nodes)\n",
106
+ "\n",
107
+ "G.add_edge(1, 2, weight=4)\n",
108
+ "G.add_edge(2, 3, weight=2)\n",
109
+ "G.add_edge(3, 4, weight=7)\n",
110
+ "G.add_edge(5, 1, weight=5)\n",
111
+ "G.add_edge(2, 5, weight=3)\n",
112
+ "G.add_edge(3, 1, weight=6)\n",
113
+ "G.add_edge(4, 1, weight=8)\n",
114
+ "G.add_edge(5, 3, weight=2)\n",
115
+ "\n",
116
+ "print(\"Edges:\", G.edges)\n",
117
+ "print(\"Edges with data:\", G.edges.data())\n",
118
+ "\n",
119
+ "total_deg = dict(G.degree())\n",
120
+ "print(\"Total Degrees:\", total_deg)\n",
121
+ "\n",
122
+ "node_sizes = [total_deg[n] * 700 for n in G.nodes()]\n",
123
+ "print(\"Node Sizes:\", node_sizes)\n",
124
+ "\n",
125
+ "edge_weights = [G[u][v]['weight'] for u, v in G.edges()]\n",
126
+ "edge_widths = [w * 0.5 for w in edge_weights]\n",
127
+ "print(\"Edge Weights:\", edge_weights)\n",
128
+ "print(\"Edge Widths:\", edge_widths)\n",
129
+ "\n",
130
+ "# Different layouts\n",
131
+ "#pos = nx.kamada_kawai_layout(G, weight='weight')\n",
132
+ "#pos = nx.spring_layout(G, weight='weight', seed=42)\n",
133
+ "pos = nx.circular_layout(G)\n",
134
+ "\n",
135
+ "plt.figure(figsize=(8, 6))\n",
136
+ "nx.draw(G, pos=pos, with_labels=True,\n",
137
+ " node_size=node_sizes,\n",
138
+ " width=edge_widths,\n",
139
+ " node_color='pink',\n",
140
+ " edge_color='blue',\n",
141
+ " arrows=False)\n",
142
+ "\n",
143
+ "edge_labels = nx.get_edge_attributes(G, 'weight')\n",
144
+ "nx.draw_networkx_edge_labels(G, pos=pos, edge_labels=edge_labels)\n",
145
+ "\n",
146
+ "plt.title(\"Undirected Weighted Graph\\n(Node size ∝ Degree, Edge width & length ∝ Weight)\", fontsize=11)\n",
147
+ "plt.axis('off')\n",
148
+ "plt.tight_layout()\n",
149
+ "plt.show()\n"
150
+ ]
151
+ },
152
+ {
153
+ "cell_type": "markdown",
154
+ "id": "ff426be1",
155
+ "metadata": {},
156
+ "source": [
157
+ "# **Q1(C)Plot an unweighted, undirected network such that the node size is proportional to the degree(on real world network)**"
158
+ ]
159
+ },
160
+ {
161
+ "cell_type": "code",
162
+ "execution_count": null,
163
+ "id": "6361da1f",
164
+ "metadata": {},
165
+ "outputs": [],
166
+ "source": [
167
+ "import pandas as pd\n",
168
+ "import networkx as nx\n",
169
+ "import matplotlib.pyplot as plt\n",
170
+ "\n",
171
+ "df = pd.read_csv('Bali.txt', sep='\\t', header=None, names=['Source', 'Target', 'Weight'])\n",
172
+ "\n",
173
+ "G = nx.from_pandas_edgelist(df, source='Source', target='Target', create_using=nx.Graph())\n",
174
+ "\n",
175
+ "print(\"Number of nodes:\", G.number_of_nodes())\n",
176
+ "print(\"Number of edges:\", G.number_of_edges())\n",
177
+ "print(\"\\nEdges in the graph:\")\n",
178
+ "for u, v in G.edges():\n",
179
+ " print(f\"{u} — {v}\")\n",
180
+ "\n",
181
+ "degree_dict = dict(G.degree())\n",
182
+ "node_sizes = [degree_dict[n] * 300 + 800 for n in G.nodes()]\n",
183
+ "\n",
184
+ "# different layouts ---nx.spring_layout(G) or nx.circular_layout(G)\n",
185
+ "#pos = nx.kamada_kawai_layout(G)\n",
186
+ "#pos = nx.spring_layout(G, weight='weight', seed=42)\n",
187
+ "pos = nx.circular_layout(G)\n",
188
+ "\n",
189
+ "plt.figure(figsize=(14, 10))\n",
190
+ "nx.draw(G, pos, with_labels=True,\n",
191
+ " node_color='pink',\n",
192
+ " edge_color='gray',\n",
193
+ " node_size=node_sizes,\n",
194
+ " width=1.5,\n",
195
+ " font_size=9,\n",
196
+ " font_color='black')\n",
197
+ "\n",
198
+ "plt.title(\"Bali Terrorist Network (Unweighted, Undirected)\\nNode size ∝ Degree\",\n",
199
+ " fontsize=13, color='black', pad=15)\n",
200
+ "plt.axis('off')\n",
201
+ "plt.tight_layout()\n",
202
+ "plt.show()"
203
+ ]
204
+ },
205
+ {
206
+ "cell_type": "markdown",
207
+ "id": "ce5b22a5",
208
+ "metadata": {},
209
+ "source": [
210
+ "# **Q1(D)Plot a weighted, directed network such that the node size and edge width are proportional to the in-degree and edge weight respectively(on real world network)**"
211
+ ]
212
+ },
213
+ {
214
+ "cell_type": "code",
215
+ "execution_count": null,
216
+ "id": "1de0c9cb",
217
+ "metadata": {},
218
+ "outputs": [],
219
+ "source": [
220
+ "import pandas as pd\n",
221
+ "import networkx as nx\n",
222
+ "import matplotlib.pyplot as plt\n",
223
+ "\n",
224
+ "df = pd.read_csv('Bali.txt', sep='\\t', header=None, names=['Source', 'Target', 'Weight'])\n",
225
+ "\n",
226
+ "G = nx.from_pandas_edgelist(df, source='Source', target='Target', edge_attr='Weight', create_using=nx.DiGraph())\n",
227
+ "\n",
228
+ "print(\"Number of nodes:\", G.number_of_nodes())\n",
229
+ "print(\"Number of edges:\", G.number_of_edges())\n",
230
+ "print(\"\\nEdges in the graph (with weights):\")\n",
231
+ "for u, v, data in G.edges(data=True):\n",
232
+ " print(f\"{u} → {v} (weight = {data['Weight']})\")\n",
233
+ "\n",
234
+ "in_deg = dict(G.in_degree())\n",
235
+ "node_sizes = [in_deg[n] * 300 + 800 for n in G.nodes()]\n",
236
+ "\n",
237
+ "edge_widths = [data['Weight'] * 0.3 for _, _, data in G.edges(data=True)]\n",
238
+ "\n",
239
+ "# Different layouts\n",
240
+ "#pos = nx.kamada_kawai_layout(G, weight='weight')\n",
241
+ "#pos = nx.spring_layout(G, weight='weight', seed=42)\n",
242
+ "pos = nx.circular_layout(G)\n",
243
+ "\n",
244
+ "plt.figure(figsize=(14, 10))\n",
245
+ "nx.draw(G, pos, with_labels=True,\n",
246
+ " node_color='pink',\n",
247
+ " edge_color='darkblue',\n",
248
+ " node_size=node_sizes,\n",
249
+ " width=edge_widths,\n",
250
+ " arrows=True,\n",
251
+ " font_size=9,\n",
252
+ " font_color='black')\n",
253
+ "\n",
254
+ "edge_labels = nx.get_edge_attributes(G, 'Weight')\n",
255
+ "nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels, font_size=8, font_color='black')\n",
256
+ "\n",
257
+ "plt.title(\"Bali Terrorist Network (Weighted, Directed)\\nNode size ∝ In-degree, Edge width ∝ Weight\",\n",
258
+ " fontsize=13, color='black', pad=15)\n",
259
+ "plt.axis('off')\n",
260
+ "plt.tight_layout()\n",
261
+ "plt.show()\n"
262
+ ]
263
+ }
264
+ ],
265
+ "metadata": {
266
+ "kernelspec": {
267
+ "display_name": "Python 3",
268
+ "language": "python",
269
+ "name": "python3"
270
+ },
271
+ "language_info": {
272
+ "codemirror_mode": {
273
+ "name": "ipython",
274
+ "version": 3
275
+ },
276
+ "file_extension": ".py",
277
+ "mimetype": "text/x-python",
278
+ "name": "python",
279
+ "nbconvert_exporter": "python",
280
+ "pygments_lexer": "ipython3",
281
+ "version": "3.10.12"
282
+ }
283
+ },
284
+ "nbformat": 4,
285
+ "nbformat_minor": 5
286
+ }