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,592 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "564f7abe",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Q2: Community Detection in Random Networks\n",
9
+ "\n",
10
+ "This notebook demonstrates community detection using different algorithms:\n",
11
+ "- k-clique communities\n",
12
+ "- k-clan communities\n",
13
+ "- k-plex communities\n",
14
+ "- k-core decomposition\n",
15
+ "\n",
16
+ "We'll generate a random network with 1000 nodes and compare the characteristics of communities found by each method."
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "markdown",
21
+ "id": "2b647b78",
22
+ "metadata": {},
23
+ "source": [
24
+ "## 1. Import Required Libraries"
25
+ ]
26
+ },
27
+ {
28
+ "cell_type": "code",
29
+ "execution_count": null,
30
+ "id": "48d93307",
31
+ "metadata": {},
32
+ "outputs": [],
33
+ "source": [
34
+ "import networkx as nx\n",
35
+ "import matplotlib.pyplot as plt\n",
36
+ "import numpy as np\n",
37
+ "from collections import Counter\n",
38
+ "import warnings\n",
39
+ "warnings.filterwarnings('ignore')\n",
40
+ "\n",
41
+ "# Set random seed for reproducibility\n",
42
+ "np.random.seed(42)"
43
+ ]
44
+ },
45
+ {
46
+ "cell_type": "markdown",
47
+ "id": "632b0f17",
48
+ "metadata": {},
49
+ "source": [
50
+ "## 2. Generate Random Network with 1000 Nodes"
51
+ ]
52
+ },
53
+ {
54
+ "cell_type": "code",
55
+ "execution_count": null,
56
+ "id": "0b7e15a1",
57
+ "metadata": {},
58
+ "outputs": [],
59
+ "source": [
60
+ "# Generate a random network using Erdos-Renyi model\n",
61
+ "# Using probability p=0.005 to create a moderately connected network\n",
62
+ "n_nodes = 1000\n",
63
+ "p = 0.005 # Edge probability\n",
64
+ "\n",
65
+ "G = nx.erdos_renyi_graph(n_nodes, p, seed=42)\n",
66
+ "\n",
67
+ "print(f\"Network created with {G.number_of_nodes()} nodes and {G.number_of_edges()} edges\")\n",
68
+ "print(f\"Average degree: {2 * G.number_of_edges() / G.number_of_nodes():.2f}\")\n",
69
+ "print(f\"Density: {nx.density(G):.4f}\")\n",
70
+ "print(f\"Number of connected components: {nx.number_connected_components(G)}\")"
71
+ ]
72
+ },
73
+ {
74
+ "cell_type": "markdown",
75
+ "id": "aaa12097",
76
+ "metadata": {},
77
+ "source": [
78
+ "## 3. k-Clique Communities\n",
79
+ "\n",
80
+ "k-clique communities are defined as the union of all cliques of size k that can be reached through adjacent cliques."
81
+ ]
82
+ },
83
+ {
84
+ "cell_type": "code",
85
+ "execution_count": null,
86
+ "id": "fb68588e",
87
+ "metadata": {},
88
+ "outputs": [],
89
+ "source": [
90
+ "# Find k-clique communities (using k=3 for triangles)\n",
91
+ "k_clique = 3\n",
92
+ "clique_communities = list(nx.community.k_clique_communities(G, k_clique))\n",
93
+ "\n",
94
+ "print(f\"\\n=== k-CLIQUE COMMUNITIES (k={k_clique}) ===\")\n",
95
+ "print(f\"Number of communities: {len(clique_communities)}\")\n",
96
+ "\n",
97
+ "# Calculate sizes of communities\n",
98
+ "clique_sizes = [len(comm) for comm in clique_communities]\n",
99
+ "if clique_sizes:\n",
100
+ " print(f\"Average community size: {np.mean(clique_sizes):.2f}\")\n",
101
+ " print(f\"Largest community size: {max(clique_sizes)}\")\n",
102
+ " print(f\"Smallest community size: {min(clique_sizes)}\")\n",
103
+ " print(f\"Median community size: {np.median(clique_sizes):.2f}\")\n",
104
+ "else:\n",
105
+ " print(\"No k-clique communities found\")"
106
+ ]
107
+ },
108
+ {
109
+ "cell_type": "markdown",
110
+ "id": "45bf5fe4",
111
+ "metadata": {},
112
+ "source": [
113
+ "## 4. k-Core Decomposition\n",
114
+ "\n",
115
+ "k-core is a maximal subgraph where every node has at least k neighbors within the subgraph."
116
+ ]
117
+ },
118
+ {
119
+ "cell_type": "code",
120
+ "execution_count": null,
121
+ "id": "39be4e8d",
122
+ "metadata": {},
123
+ "outputs": [],
124
+ "source": [
125
+ "# Find k-core decomposition\n",
126
+ "core_numbers = nx.core_number(G)\n",
127
+ "\n",
128
+ "print(f\"\\n=== k-CORE DECOMPOSITION ===\")\n",
129
+ "print(f\"Maximum core number: {max(core_numbers.values())}\")\n",
130
+ "print(f\"Minimum core number: {min(core_numbers.values())}\")\n",
131
+ "\n",
132
+ "# Group nodes by their core number\n",
133
+ "core_distribution = Counter(core_numbers.values())\n",
134
+ "print(f\"\\nCore distribution:\")\n",
135
+ "for k in sorted(core_distribution.keys()):\n",
136
+ " print(f\" k-core {k}: {core_distribution[k]} nodes\")\n",
137
+ "\n",
138
+ "# Extract different k-cores\n",
139
+ "max_k = max(core_numbers.values())\n",
140
+ "k_cores = {}\n",
141
+ "for k in range(1, max_k + 1):\n",
142
+ " k_cores[k] = nx.k_core(G, k)\n",
143
+ " print(f\"\\nk-core (k={k}): {k_cores[k].number_of_nodes()} nodes, {k_cores[k].number_of_edges()} edges\")"
144
+ ]
145
+ },
146
+ {
147
+ "cell_type": "markdown",
148
+ "id": "55f13ae2",
149
+ "metadata": {},
150
+ "source": [
151
+ "## 5. k-Plex Communities\n",
152
+ "\n",
153
+ "A k-plex is a relaxed clique where each node can miss connections to at most k-1 other nodes in the group.\n",
154
+ "\n",
155
+ "Note: NetworkX doesn't have a built-in k-plex algorithm, so we'll implement a simple version for finding maximal k-plexes."
156
+ ]
157
+ },
158
+ {
159
+ "cell_type": "code",
160
+ "execution_count": null,
161
+ "id": "a7c236e7",
162
+ "metadata": {},
163
+ "outputs": [],
164
+ "source": [
165
+ "def find_k_plex(G, k, min_size=3):\n",
166
+ " \"\"\"\n",
167
+ " Find k-plex subgraphs in G.\n",
168
+ " A k-plex is a subgraph where each node is connected to at least n-k nodes in the subgraph,\n",
169
+ " where n is the size of the subgraph.\n",
170
+ " \"\"\"\n",
171
+ " k_plexes = []\n",
172
+ " \n",
173
+ " # Use cliques as starting points and relax them\n",
174
+ " cliques = list(nx.find_cliques(G))\n",
175
+ " \n",
176
+ " for clique in cliques:\n",
177
+ " if len(clique) >= min_size:\n",
178
+ " # Check if it's a k-plex\n",
179
+ " is_k_plex = True\n",
180
+ " for node in clique:\n",
181
+ " neighbors_in_clique = len([n for n in clique if n in G.neighbors(node)])\n",
182
+ " # Each node should be connected to at least (size - k) nodes\n",
183
+ " if neighbors_in_clique < len(clique) - k:\n",
184
+ " is_k_plex = False\n",
185
+ " break\n",
186
+ " \n",
187
+ " if is_k_plex:\n",
188
+ " k_plexes.append(set(clique))\n",
189
+ " \n",
190
+ " # Remove duplicates\n",
191
+ " unique_plexes = []\n",
192
+ " for plex in k_plexes:\n",
193
+ " if plex not in unique_plexes:\n",
194
+ " unique_plexes.append(plex)\n",
195
+ " \n",
196
+ " return unique_plexes\n",
197
+ "\n",
198
+ "# Find k-plex communities\n",
199
+ "k_plex = 2\n",
200
+ "plex_communities = find_k_plex(G, k_plex, min_size=3)\n",
201
+ "\n",
202
+ "print(f\"\\n=== k-PLEX COMMUNITIES (k={k_plex}) ===\")\n",
203
+ "print(f\"Number of k-plex communities found: {len(plex_communities)}\")\n",
204
+ "\n",
205
+ "if plex_communities:\n",
206
+ " plex_sizes = [len(comm) for comm in plex_communities]\n",
207
+ " print(f\"Average k-plex size: {np.mean(plex_sizes):.2f}\")\n",
208
+ " print(f\"Largest k-plex size: {max(plex_sizes)}\")\n",
209
+ " print(f\"Smallest k-plex size: {min(plex_sizes)}\")\n",
210
+ " print(f\"Median k-plex size: {np.median(plex_sizes):.2f}\")\n",
211
+ "else:\n",
212
+ " print(\"No k-plex communities found\")"
213
+ ]
214
+ },
215
+ {
216
+ "cell_type": "markdown",
217
+ "id": "dd50ed9b",
218
+ "metadata": {},
219
+ "source": [
220
+ "## 6. k-Clan Communities\n",
221
+ "\n",
222
+ "A k-clan is a k-clique community with the additional constraint that the diameter within the community is at most k.\n",
223
+ "\n",
224
+ "Note: NetworkX doesn't have a built-in k-clan algorithm, so we'll implement a version based on cliques."
225
+ ]
226
+ },
227
+ {
228
+ "cell_type": "code",
229
+ "execution_count": null,
230
+ "id": "13e1423d",
231
+ "metadata": {},
232
+ "outputs": [],
233
+ "source": [
234
+ "def find_k_clans(G, k, min_size=3):\n",
235
+ " \"\"\"\n",
236
+ " Find k-clan communities.\n",
237
+ " A k-clan is a k-clique where the diameter is at most k.\n",
238
+ " \"\"\"\n",
239
+ " k_clans = []\n",
240
+ " \n",
241
+ " # Find all cliques of size at least k\n",
242
+ " cliques = [c for c in nx.find_cliques(G) if len(c) >= min_size]\n",
243
+ " \n",
244
+ " for clique in cliques:\n",
245
+ " # Check if the diameter of the subgraph is at most k\n",
246
+ " subG = G.subgraph(clique)\n",
247
+ " \n",
248
+ " if nx.is_connected(subG):\n",
249
+ " diameter = nx.diameter(subG)\n",
250
+ " if diameter <= k:\n",
251
+ " k_clans.append(set(clique))\n",
252
+ " \n",
253
+ " # Remove duplicates\n",
254
+ " unique_clans = []\n",
255
+ " for clan in k_clans:\n",
256
+ " if clan not in unique_clans:\n",
257
+ " unique_clans.append(clan)\n",
258
+ " \n",
259
+ " return unique_clans\n",
260
+ "\n",
261
+ "# Find k-clan communities\n",
262
+ "k_clan = 3\n",
263
+ "clan_communities = find_k_clans(G, k_clan, min_size=3)\n",
264
+ "\n",
265
+ "print(f\"\\n=== k-CLAN COMMUNITIES (k={k_clan}) ===\")\n",
266
+ "print(f\"Number of k-clan communities found: {len(clan_communities)}\")\n",
267
+ "\n",
268
+ "if clan_communities:\n",
269
+ " clan_sizes = [len(comm) for comm in clan_communities]\n",
270
+ " print(f\"Average k-clan size: {np.mean(clan_sizes):.2f}\")\n",
271
+ " print(f\"Largest k-clan size: {max(clan_sizes)}\")\n",
272
+ " print(f\"Smallest k-clan size: {min(clan_sizes)}\")\n",
273
+ " print(f\"Median k-clan size: {np.median(clan_sizes):.2f}\")\n",
274
+ "else:\n",
275
+ " print(\"No k-clan communities found\")"
276
+ ]
277
+ },
278
+ {
279
+ "cell_type": "markdown",
280
+ "id": "1ab25e6b",
281
+ "metadata": {},
282
+ "source": [
283
+ "## 7. Visualization of Communities"
284
+ ]
285
+ },
286
+ {
287
+ "cell_type": "code",
288
+ "execution_count": null,
289
+ "id": "f14a2eee",
290
+ "metadata": {},
291
+ "outputs": [],
292
+ "source": [
293
+ "# Create visualizations for each method\n",
294
+ "fig, axes = plt.subplots(2, 2, figsize=(16, 16))\n",
295
+ "fig.suptitle('Community Detection Methods Comparison', fontsize=16, fontweight='bold')\n",
296
+ "\n",
297
+ "# Use the largest connected component for better visualization\n",
298
+ "largest_cc = max(nx.connected_components(G), key=len)\n",
299
+ "G_vis = G.subgraph(largest_cc).copy()\n",
300
+ "pos = nx.spring_layout(G_vis, k=0.5, iterations=50, seed=42)\n",
301
+ "\n",
302
+ "# 1. k-Clique Communities Visualization\n",
303
+ "ax1 = axes[0, 0]\n",
304
+ "nx.draw_networkx_edges(G_vis, pos, alpha=0.1, ax=ax1)\n",
305
+ "colors_clique = ['lightgray'] * len(G_vis.nodes())\n",
306
+ "node_list = list(G_vis.nodes())\n",
307
+ "\n",
308
+ "if clique_communities:\n",
309
+ " color_map = plt.cm.get_cmap('tab20', len(clique_communities))\n",
310
+ " for i, comm in enumerate(clique_communities[:20]): # Limit to 20 for visualization\n",
311
+ " comm_in_vis = [n for n in comm if n in G_vis.nodes()]\n",
312
+ " for node in comm_in_vis:\n",
313
+ " idx = node_list.index(node)\n",
314
+ " colors_clique[idx] = color_map(i)\n",
315
+ "\n",
316
+ "nx.draw_networkx_nodes(G_vis, pos, node_color=colors_clique, node_size=30, ax=ax1)\n",
317
+ "ax1.set_title(f'k-Clique Communities (k={k_clique})\\n{len(clique_communities)} communities found', fontsize=12)\n",
318
+ "ax1.axis('off')\n",
319
+ "\n",
320
+ "# 2. k-Core Visualization\n",
321
+ "ax2 = axes[0, 1]\n",
322
+ "nx.draw_networkx_edges(G_vis, pos, alpha=0.1, ax=ax2)\n",
323
+ "core_colors = [core_numbers.get(node, 0) for node in G_vis.nodes()]\n",
324
+ "nx.draw_networkx_nodes(G_vis, pos, node_color=core_colors, node_size=30, \n",
325
+ " cmap='viridis', ax=ax2, vmin=0, vmax=max(core_numbers.values()))\n",
326
+ "ax2.set_title(f'k-Core Decomposition\\nMax core: {max(core_numbers.values())}', fontsize=12)\n",
327
+ "ax2.axis('off')\n",
328
+ "\n",
329
+ "# 3. k-Plex Communities Visualization\n",
330
+ "ax3 = axes[1, 0]\n",
331
+ "nx.draw_networkx_edges(G_vis, pos, alpha=0.1, ax=ax3)\n",
332
+ "colors_plex = ['lightgray'] * len(G_vis.nodes())\n",
333
+ "\n",
334
+ "if plex_communities:\n",
335
+ " color_map = plt.cm.get_cmap('tab20', len(plex_communities))\n",
336
+ " for i, comm in enumerate(plex_communities[:20]): # Limit to 20 for visualization\n",
337
+ " comm_in_vis = [n for n in comm if n in G_vis.nodes()]\n",
338
+ " for node in comm_in_vis:\n",
339
+ " idx = node_list.index(node)\n",
340
+ " colors_plex[idx] = color_map(i)\n",
341
+ "\n",
342
+ "nx.draw_networkx_nodes(G_vis, pos, node_color=colors_plex, node_size=30, ax=ax3)\n",
343
+ "ax3.set_title(f'k-Plex Communities (k={k_plex})\\n{len(plex_communities)} communities found', fontsize=12)\n",
344
+ "ax3.axis('off')\n",
345
+ "\n",
346
+ "# 4. k-Clan Communities Visualization\n",
347
+ "ax4 = axes[1, 1]\n",
348
+ "nx.draw_networkx_edges(G_vis, pos, alpha=0.1, ax=ax4)\n",
349
+ "colors_clan = ['lightgray'] * len(G_vis.nodes())\n",
350
+ "\n",
351
+ "if clan_communities:\n",
352
+ " color_map = plt.cm.get_cmap('tab20', len(clan_communities))\n",
353
+ " for i, comm in enumerate(clan_communities[:20]): # Limit to 20 for visualization\n",
354
+ " comm_in_vis = [n for n in comm if n in G_vis.nodes()]\n",
355
+ " for node in comm_in_vis:\n",
356
+ " idx = node_list.index(node)\n",
357
+ " colors_clan[idx] = color_map(i)\n",
358
+ "\n",
359
+ "nx.draw_networkx_nodes(G_vis, pos, node_color=colors_clan, node_size=30, ax=ax4)\n",
360
+ "ax4.set_title(f'k-Clan Communities (k={k_clan})\\n{len(clan_communities)} communities found', fontsize=12)\n",
361
+ "ax4.axis('off')\n",
362
+ "\n",
363
+ "plt.tight_layout()\n",
364
+ "plt.savefig('community_detection_comparison.png', dpi=300, bbox_inches='tight')\n",
365
+ "plt.show()\n",
366
+ "\n",
367
+ "print(\"\\nVisualization saved as 'community_detection_comparison.png'\")"
368
+ ]
369
+ },
370
+ {
371
+ "cell_type": "markdown",
372
+ "id": "b8054688",
373
+ "metadata": {},
374
+ "source": [
375
+ "## 8. Comparison of Community Characteristics"
376
+ ]
377
+ },
378
+ {
379
+ "cell_type": "code",
380
+ "execution_count": null,
381
+ "id": "22fd6f5e",
382
+ "metadata": {},
383
+ "outputs": [],
384
+ "source": [
385
+ "# Create comparison table\n",
386
+ "import pandas as pd\n",
387
+ "\n",
388
+ "comparison_data = {\n",
389
+ " 'Method': [],\n",
390
+ " 'Number of Communities': [],\n",
391
+ " 'Avg Size': [],\n",
392
+ " 'Min Size': [],\n",
393
+ " 'Max Size': [],\n",
394
+ " 'Median Size': [],\n",
395
+ " 'Total Nodes Covered': []\n",
396
+ "}\n",
397
+ "\n",
398
+ "# k-Clique\n",
399
+ "comparison_data['Method'].append(f'k-Clique (k={k_clique})')\n",
400
+ "comparison_data['Number of Communities'].append(len(clique_communities))\n",
401
+ "if clique_sizes:\n",
402
+ " comparison_data['Avg Size'].append(f\"{np.mean(clique_sizes):.2f}\")\n",
403
+ " comparison_data['Min Size'].append(min(clique_sizes))\n",
404
+ " comparison_data['Max Size'].append(max(clique_sizes))\n",
405
+ " comparison_data['Median Size'].append(f\"{np.median(clique_sizes):.2f}\")\n",
406
+ " comparison_data['Total Nodes Covered'].append(len(set().union(*clique_communities)))\n",
407
+ "else:\n",
408
+ " comparison_data['Avg Size'].append('N/A')\n",
409
+ " comparison_data['Min Size'].append('N/A')\n",
410
+ " comparison_data['Max Size'].append('N/A')\n",
411
+ " comparison_data['Median Size'].append('N/A')\n",
412
+ " comparison_data['Total Nodes Covered'].append(0)\n",
413
+ "\n",
414
+ "# k-Core (using cores with at least 1 node)\n",
415
+ "k_core_communities = [set([n for n, c in core_numbers.items() if c == k]) for k in set(core_numbers.values())]\n",
416
+ "k_core_communities = [c for c in k_core_communities if len(c) > 0]\n",
417
+ "k_core_sizes = [len(c) for c in k_core_communities]\n",
418
+ "\n",
419
+ "comparison_data['Method'].append('k-Core')\n",
420
+ "comparison_data['Number of Communities'].append(len(k_core_communities))\n",
421
+ "comparison_data['Avg Size'].append(f\"{np.mean(k_core_sizes):.2f}\")\n",
422
+ "comparison_data['Min Size'].append(min(k_core_sizes))\n",
423
+ "comparison_data['Max Size'].append(max(k_core_sizes))\n",
424
+ "comparison_data['Median Size'].append(f\"{np.median(k_core_sizes):.2f}\")\n",
425
+ "comparison_data['Total Nodes Covered'].append(len(set().union(*k_core_communities)))\n",
426
+ "\n",
427
+ "# k-Plex\n",
428
+ "comparison_data['Method'].append(f'k-Plex (k={k_plex})')\n",
429
+ "comparison_data['Number of Communities'].append(len(plex_communities))\n",
430
+ "if plex_sizes:\n",
431
+ " comparison_data['Avg Size'].append(f\"{np.mean(plex_sizes):.2f}\")\n",
432
+ " comparison_data['Min Size'].append(min(plex_sizes))\n",
433
+ " comparison_data['Max Size'].append(max(plex_sizes))\n",
434
+ " comparison_data['Median Size'].append(f\"{np.median(plex_sizes):.2f}\")\n",
435
+ " comparison_data['Total Nodes Covered'].append(len(set().union(*plex_communities)))\n",
436
+ "else:\n",
437
+ " comparison_data['Avg Size'].append('N/A')\n",
438
+ " comparison_data['Min Size'].append('N/A')\n",
439
+ " comparison_data['Max Size'].append('N/A')\n",
440
+ " comparison_data['Median Size'].append('N/A')\n",
441
+ " comparison_data['Total Nodes Covered'].append(0)\n",
442
+ "\n",
443
+ "# k-Clan\n",
444
+ "comparison_data['Method'].append(f'k-Clan (k={k_clan})')\n",
445
+ "comparison_data['Number of Communities'].append(len(clan_communities))\n",
446
+ "if clan_sizes:\n",
447
+ " comparison_data['Avg Size'].append(f\"{np.mean(clan_sizes):.2f}\")\n",
448
+ " comparison_data['Min Size'].append(min(clan_sizes))\n",
449
+ " comparison_data['Max Size'].append(max(clan_sizes))\n",
450
+ " comparison_data['Median Size'].append(f\"{np.median(clan_sizes):.2f}\")\n",
451
+ " comparison_data['Total Nodes Covered'].append(len(set().union(*clan_communities)))\n",
452
+ "else:\n",
453
+ " comparison_data['Avg Size'].append('N/A')\n",
454
+ " comparison_data['Min Size'].append('N/A')\n",
455
+ " comparison_data['Max Size'].append('N/A')\n",
456
+ " comparison_data['Median Size'].append('N/A')\n",
457
+ " comparison_data['Total Nodes Covered'].append(0)\n",
458
+ "\n",
459
+ "df_comparison = pd.DataFrame(comparison_data)\n",
460
+ "print(\"\\n\" + \"=\"*80)\n",
461
+ "print(\"COMPREHENSIVE COMPARISON OF COMMUNITY DETECTION METHODS\")\n",
462
+ "print(\"=\"*80)\n",
463
+ "print(df_comparison.to_string(index=False))\n",
464
+ "print(\"=\"*80)"
465
+ ]
466
+ },
467
+ {
468
+ "cell_type": "markdown",
469
+ "id": "2df81061",
470
+ "metadata": {},
471
+ "source": [
472
+ "## 9. Size Distribution Comparison"
473
+ ]
474
+ },
475
+ {
476
+ "cell_type": "code",
477
+ "execution_count": null,
478
+ "id": "6a86b65b",
479
+ "metadata": {},
480
+ "outputs": [],
481
+ "source": [
482
+ "# Plot size distributions\n",
483
+ "fig, axes = plt.subplots(2, 2, figsize=(14, 10))\n",
484
+ "fig.suptitle('Community Size Distributions', fontsize=16, fontweight='bold')\n",
485
+ "\n",
486
+ "# k-Clique\n",
487
+ "if clique_sizes:\n",
488
+ " axes[0, 0].hist(clique_sizes, bins=20, color='skyblue', edgecolor='black', alpha=0.7)\n",
489
+ " axes[0, 0].set_xlabel('Community Size')\n",
490
+ " axes[0, 0].set_ylabel('Frequency')\n",
491
+ " axes[0, 0].set_title(f'k-Clique (k={k_clique})')\n",
492
+ " axes[0, 0].grid(True, alpha=0.3)\n",
493
+ "else:\n",
494
+ " axes[0, 0].text(0.5, 0.5, 'No communities found', ha='center', va='center')\n",
495
+ " axes[0, 0].set_title(f'k-Clique (k={k_clique})')\n",
496
+ "\n",
497
+ "# k-Core\n",
498
+ "axes[0, 1].hist(k_core_sizes, bins=20, color='lightcoral', edgecolor='black', alpha=0.7)\n",
499
+ "axes[0, 1].set_xlabel('Community Size')\n",
500
+ "axes[0, 1].set_ylabel('Frequency')\n",
501
+ "axes[0, 1].set_title('k-Core')\n",
502
+ "axes[0, 1].grid(True, alpha=0.3)\n",
503
+ "\n",
504
+ "# k-Plex\n",
505
+ "if plex_sizes:\n",
506
+ " axes[1, 0].hist(plex_sizes, bins=20, color='lightgreen', edgecolor='black', alpha=0.7)\n",
507
+ " axes[1, 0].set_xlabel('Community Size')\n",
508
+ " axes[1, 0].set_ylabel('Frequency')\n",
509
+ " axes[1, 0].set_title(f'k-Plex (k={k_plex})')\n",
510
+ " axes[1, 0].grid(True, alpha=0.3)\n",
511
+ "else:\n",
512
+ " axes[1, 0].text(0.5, 0.5, 'No communities found', ha='center', va='center')\n",
513
+ " axes[1, 0].set_title(f'k-Plex (k={k_plex})')\n",
514
+ "\n",
515
+ "# k-Clan\n",
516
+ "if clan_sizes:\n",
517
+ " axes[1, 1].hist(clan_sizes, bins=20, color='plum', edgecolor='black', alpha=0.7)\n",
518
+ " axes[1, 1].set_xlabel('Community Size')\n",
519
+ " axes[1, 1].set_ylabel('Frequency')\n",
520
+ " axes[1, 1].set_title(f'k-Clan (k={k_clan})')\n",
521
+ " axes[1, 1].grid(True, alpha=0.3)\n",
522
+ "else:\n",
523
+ " axes[1, 1].text(0.5, 0.5, 'No communities found', ha='center', va='center')\n",
524
+ " axes[1, 1].set_title(f'k-Clan (k={k_clan})')\n",
525
+ "\n",
526
+ "plt.tight_layout()\n",
527
+ "plt.savefig('community_size_distributions.png', dpi=300, bbox_inches='tight')\n",
528
+ "plt.show()\n",
529
+ "\n",
530
+ "print(\"\\nSize distribution visualization saved as 'community_size_distributions.png'\")"
531
+ ]
532
+ },
533
+ {
534
+ "cell_type": "markdown",
535
+ "id": "3cc0c99c",
536
+ "metadata": {},
537
+ "source": [
538
+ "## 10. Summary and Insights"
539
+ ]
540
+ },
541
+ {
542
+ "cell_type": "code",
543
+ "execution_count": null,
544
+ "id": "7be090c8",
545
+ "metadata": {},
546
+ "outputs": [],
547
+ "source": [
548
+ "print(\"\\n\" + \"=\"*80)\n",
549
+ "print(\"SUMMARY AND INSIGHTS\")\n",
550
+ "print(\"=\"*80)\n",
551
+ "\n",
552
+ "print(\"\\n1. k-Clique Communities:\")\n",
553
+ "print(\" - Identifies communities based on overlapping cliques\")\n",
554
+ "print(\" - Tends to find larger, more interconnected communities\")\n",
555
+ "print(\" - Communities can overlap (nodes can belong to multiple communities)\")\n",
556
+ "\n",
557
+ "print(\"\\n2. k-Core Decomposition:\")\n",
558
+ "print(\" - Identifies hierarchical layers of network density\")\n",
559
+ "print(\" - Each node is assigned a core number based on degree\")\n",
560
+ "print(\" - Higher k-cores represent more tightly connected groups\")\n",
561
+ "print(\" - Non-overlapping partition of the network\")\n",
562
+ "\n",
563
+ "print(\"\\n3. k-Plex Communities:\")\n",
564
+ "print(\" - Relaxed version of cliques (allows some missing edges)\")\n",
565
+ "print(\" - More flexible than strict cliques\")\n",
566
+ "print(\" - Can identify cohesive subgroups with minor gaps in connectivity\")\n",
567
+ "\n",
568
+ "print(\"\\n4. k-Clan Communities:\")\n",
569
+ "print(\" - Combines clique structure with diameter constraint\")\n",
570
+ "print(\" - Ensures members are within k steps of each other\")\n",
571
+ "print(\" - Identifies tightly-knit communities with short paths\")\n",
572
+ "\n",
573
+ "print(\"\\n\" + \"=\"*80)\n",
574
+ "print(\"KEY DIFFERENCES:\")\n",
575
+ "print(\"=\"*80)\n",
576
+ "print(\"- k-Clique and k-Clan focus on clique-based structures\")\n",
577
+ "print(\"- k-Plex allows for relaxed connectivity within communities\")\n",
578
+ "print(\"- k-Core emphasizes degree-based hierarchy\")\n",
579
+ "print(\"- k-Clique, k-Plex, and k-Clan can produce overlapping communities\")\n",
580
+ "print(\"- k-Core produces a strict hierarchical decomposition\")\n",
581
+ "print(\"=\"*80)"
582
+ ]
583
+ }
584
+ ],
585
+ "metadata": {
586
+ "language_info": {
587
+ "name": "python"
588
+ }
589
+ },
590
+ "nbformat": 4,
591
+ "nbformat_minor": 5
592
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 AJ
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,75 @@
1
+ Metadata-Version: 2.1
2
+ Name: juneja-codebase
3
+ Version: 0.1.3
4
+ Summary: CLI tool to generate academic practical code files for Compiler Design, Data Structures, OS, and DBMS
5
+ Home-page: UNKNOWN
6
+ Author: AJ
7
+ License: UNKNOWN
8
+ Platform: UNKNOWN
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Intended Audience :: Education
13
+ Requires-Python: >=3.6
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+
17
+ # reqcode-aj
18
+
19
+ A Python CLI tool to generate academic practical code files offline.
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ pip install reqcode-aj
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### Standard Method
30
+ ```bash
31
+ # List available subjects
32
+ reqcode --list
33
+
34
+ # Generate all code files
35
+ reqcode --all
36
+
37
+ # Generate specific subject
38
+ reqcode --subject compiler_design
39
+
40
+ # Save to specific directory
41
+ reqcode --all --output ./my_codes
42
+
43
+ # Create zip file
44
+ reqcode --all --zip
45
+ ```
46
+
47
+ ### Alternative Method (Use this in lab/college systems if `reqcode` command doesn't work)
48
+ ```bash
49
+ # If you get "command not found" or "not recognized" error, use:
50
+ python -m reqcode_aj.main --list
51
+ python -m reqcode_aj.main --all
52
+ python -m reqcode_aj.main --subject compiler_design
53
+ python -m reqcode_aj.main --all --zip
54
+ ```
55
+
56
+ **Note:** The alternative method works on ALL systems and doesn't require the Scripts folder to be in PATH.
57
+
58
+ ## Subjects Included
59
+
60
+ 1. **Compiler Design** - Lex and Yacc practical files
61
+ 2. **Deep Learning** - Deep learning implementations
62
+ 3. **Social Network Analysis** - Network analysis code
63
+
64
+ ## Features
65
+
66
+ - Works completely offline
67
+ - All practical files bundled in the package
68
+ - Perfect for lab practicals and exam preparation
69
+ - No internet required after installation
70
+
71
+ ## License
72
+
73
+ MIT License
74
+
75
+