stuzha 0.2.7__tar.gz → 0.2.8__tar.gz

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.
@@ -1,5 +1,5 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stuzha
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Requires-Dist: colorama>=0.4.6
5
5
  Dynamic: requires-dist
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='stuzha',
5
- version='0.2.7',
5
+ version='0.2.8',
6
6
  packages=find_packages(),
7
7
  install_requires=[
8
8
  'colorama>=0.4.6',
@@ -179,6 +179,9 @@ def ans_5():
179
179
  library(igraph)
180
180
  g <- erdos.renyi.game(10, 0.3, directed = T)
181
181
  g1 <- sample_gnp(10, 0.3, directed = T)
182
+
183
+ # Density
184
+
182
185
  den <- graph.density(g)
183
186
  den
184
187
 
@@ -205,6 +208,8 @@ plot(g)
205
208
 
206
209
 
207
210
 
211
+ # Clustering
212
+
208
213
  library(igraph)
209
214
 
210
215
  kite <- make_graph("Krackhardt_Kite")
@@ -231,6 +236,9 @@ mods
231
236
 
232
237
 
233
238
 
239
+
240
+ # Centralization
241
+
234
242
  source("Practical5.2.R")
235
243
 
236
244
  optimal_edges <- which.max(mods) - 1
@@ -268,6 +276,7 @@ def ans_6():
268
276
 
269
277
  # pip install networkx, matplotlib, scipy
270
278
 
279
+ # PageRank Visualization
271
280
 
272
281
  import networkx as nx
273
282
  import matplotlib.pyplot as plt
@@ -276,36 +285,6 @@ import numpy as np
276
285
  adj = np.array([[0, 1, 1, 0], [0, 0, 1, 0], [1, 0, 0, 1], [0, 0, 1, 0]])
277
286
  nodes = ["A", "B", "C", "D"]
278
287
 
279
- G = nx.from_numpy_array(adj, create_using=nx.DiGraph)
280
- G = nx.relabel_nodes(G, {i: nodes[i] for i in range(4)})
281
- pr = nx.pagerank(G)
282
-
283
- print("PageRank Scores:", {n: f"{pr[n]:.4f}" for n in nodes})
284
-
285
- pos = {"A": (0, 1), "B": (2, 2), "C": (4, 1), "D": (2, 0)}
286
- nx.draw(G, pos, labels={n: f"{n}\n{pr[n]:.3f}" for n in nodes},
287
- node_size=[800 + 3000 * pr[n] for n in nodes],
288
- node_color="lightblue", edgecolors="darkblue",
289
- font_size=10, arrows=True, arrowsize=20)
290
- plt.title("PageRank")
291
- plt.show()
292
-
293
-
294
-
295
-
296
-
297
-
298
- # Alternate Code for PageRank Visualization
299
-
300
- import networkx as nx
301
- import matplotlib.pyplot as plt
302
- import numpy as np
303
-
304
- # Define adjacency matrix and node names
305
- adj = np.array([[0, 1, 1, 0], [0, 0, 1, 0], [1, 0, 0, 1], [0, 0, 1, 0]])
306
- nodes = ["A", "B", "C", "D"]
307
-
308
- # Create Directed Graph
309
288
  G = nx.from_numpy_array(adj, create_using=nx.DiGraph)
310
289
  G = nx.relabel_nodes(G, {i: nodes[i] for i in range(len(nodes))})
311
290
 
@@ -332,12 +311,16 @@ plt.title("PageRank Visualization")
332
311
  plt.margins(0.2)
333
312
  plt.show()
334
313
 
314
+
335
315
 
336
316
  ''')
337
317
 
338
318
  def ans_7():
339
319
  print(Fore.RED + '''
340
320
 
321
+ # Structural Equivalence
322
+
323
+
341
324
  library(sna)
342
325
  library(igraph)
343
326
 
@@ -355,6 +338,42 @@ b <- blockmodel(links2, eq, h=10)
355
338
  plot(b)
356
339
 
357
340
 
341
+
342
+
343
+ # Automorphic Equivalence
344
+
345
+ library(igraph)
346
+
347
+ links2 <- as.matrix(read.csv("edges.csv", header = TRUE, row.names = 1))
348
+
349
+ sq <- links2 %*% t(links2)
350
+ diag(sq) <- 0
351
+ sq[sq > 0] <- 1
352
+
353
+ g <- graph_from_adjacency_matrix(sq, mode = "undirected")
354
+
355
+ auto <- automorphism_group(g)
356
+
357
+ print(auto)
358
+ print(auto$orbits)
359
+
360
+
361
+
362
+
363
+ # Regular Equivalence
364
+
365
+ library(sna)
366
+
367
+ links2 <- as.matrix(read.csv("edges.csv", header = TRUE, row.names = 1))
368
+
369
+ sq <- links2 %*% t(links2)
370
+ diag(sq) <- 0
371
+
372
+ eq_reg <- equiv.clust(sq, mode = "regular")
373
+
374
+ plot(eq_reg)
375
+
376
+
358
377
  ''')
359
378
 
360
379
  def ans_8():
@@ -458,6 +477,4 @@ hamming.distance(x, w)
458
477
  hamming.distance(z, w)
459
478
  hamming.distance(x, z)
460
479
 
461
-
462
-
463
480
  ''')
@@ -1,5 +1,5 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stuzha
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Requires-Dist: colorama>=0.4.6
5
5
  Dynamic: requires-dist
File without changes
File without changes
File without changes
File without changes
File without changes