Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions small_world_propensity/small_world_propensity.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
# Probably a bad idea...
import warnings
from typing import Union

import numpy as np
import pandas as pd
import tqdm
from scipy.sparse import csgraph

warnings.filterwarnings("ignore", category=RuntimeWarning)

gen = np.random.default_rng(1337)

def small_world_propensity(
W: Union[np.ndarray, list], bin: Union[bool, list] = False
Expand Down Expand Up @@ -38,7 +33,7 @@ def small_world_propensity(

def get_avg_rad_eff(W: np.ndarray) -> int:
n = len(W)
num_con = len(np.where(W > 0)[0])
num_con = np.sum(W > 0)
avg_deg_unw = num_con / n
avg_rad_unw = avg_deg_unw / 2
avg_rad_eff = np.ceil(avg_rad_unw)
Expand Down Expand Up @@ -198,7 +193,7 @@ def randomize_matrix(A: np.ndarray) -> np.ndarray:
return A_rand


def regular_matrix_generator(G: np.ndarray, r: int) -> np.ndarray:
def regular_matrix_generator(G: np.ndarray, r: int, seed=42) -> np.ndarray:
"""Generate a regular matrix from a given matrix.

Args:
Expand All @@ -220,6 +215,7 @@ def regular_matrix_generator(G: np.ndarray, r: int) -> np.ndarray:

M = np.zeros((n, n))

gen = np.random.default_rng(seed)
for i in range(n):
for z in range(r):
a = gen.integers(0, n)
Expand Down