risk-network 0.0.14b1__py3-none-any.whl → 0.0.14b2__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.
risk/__init__.py CHANGED
@@ -8,4 +8,4 @@ RISK: Regional Inference of Significant Kinships
8
8
  from ._risk import RISK
9
9
 
10
10
  __all__ = ["RISK"]
11
- __version__ = "0.0.14-beta.1"
11
+ __version__ = "0.0.14-beta.2"
risk/_network/_io.py CHANGED
@@ -164,7 +164,7 @@ class NetworkIO:
164
164
  Args:
165
165
  compute_sphere (bool, optional): Whether to map nodes to a sphere. Defaults to True.
166
166
  surface_depth (float, optional): Surface depth for the sphere. Defaults to 0.0.
167
- min_edges_per_node (int, optional): Minimum number of edges per node. Defaults to 0.
167
+ min_edges_per_node (int, optional): Minimum number of edges per node (k-core threshold). Defaults to 0.
168
168
  """
169
169
  self.compute_sphere = compute_sphere
170
170
  self.surface_depth = surface_depth
@@ -440,20 +440,14 @@ class NetworkIO:
440
440
  num_initial_edges = G.number_of_edges()
441
441
  # Remove self-loops to ensure correct edge count
442
442
  G.remove_edges_from(nx.selfloop_edges(G))
443
- # Iteratively remove nodes with fewer edges than the threshold
444
- while True:
445
- nodes_to_remove = [
446
- node
447
- for node, degree in dict(G.degree()).items()
448
- if degree < self.min_edges_per_node
449
- ]
450
- if not nodes_to_remove:
451
- break # Exit loop if no nodes meet the condition
452
- G.remove_nodes_from(nodes_to_remove)
453
-
454
- # Remove isolated nodes
455
- isolates = list(nx.isolates(G))
456
- G.remove_nodes_from(isolates)
443
+ # Apply canonical node k-core pruning if requested
444
+ if self.min_edges_per_node > 0:
445
+ # networkx.k_core returns a subgraph; to preserve in-place behavior, copy back
446
+ core = nx.k_core(G, k=self.min_edges_per_node)
447
+ # Rebuild G in-place to keep external references valid
448
+ G.clear()
449
+ G.add_nodes_from(core.nodes(data=True))
450
+ G.add_edges_from(core.edges(data=True))
457
451
 
458
452
  # Log the number of nodes and edges before and after cleaning
459
453
  num_final_nodes = G.number_of_nodes()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: risk-network
3
- Version: 0.0.14b1
3
+ Version: 0.0.14b2
4
4
  Summary: A Python package for scalable network analysis and high-quality visualization.
5
5
  Author-email: Ira Horecka <ira89@icloud.com>
6
6
  License: GPL-3.0-or-later
@@ -1,4 +1,4 @@
1
- risk/__init__.py,sha256=EhZWpNfkex4HOMUEdfleuQ78CzIktejWJnpn8TdWr6Q,143
1
+ risk/__init__.py,sha256=Kit6ilMaj_3F16dnLJ_Dd7fE5jeZGmNqur97zzK7CRI,143
2
2
  risk/_risk.py,sha256=VULCdM41BlWKM1ou4Qc579ffZ9dMZkfhAwKYgbaEeKM,1054
3
3
  risk/_annotation/__init__.py,sha256=zr7w1DHkmvrkKFGKdPhrcvZHV-xsfd5TZOaWtFiP4Dc,164
4
4
  risk/_annotation/_annotation.py,sha256=03vcnkdi4HGH5UUyokUyOdyyjXOLoKSmLFuK7VAl41c,15174
@@ -18,7 +18,7 @@ risk/_neighborhoods/_stats/_permutation/__init__.py,sha256=nfTaW29CK8OZCdFnpMVlH
18
18
  risk/_neighborhoods/_stats/_permutation/_permutation.py,sha256=e5qVuYWGhiAn5Jv8VILk-WYMOO4km48cGdRYTOl355M,10661
19
19
  risk/_neighborhoods/_stats/_permutation/_test_functions.py,sha256=lGI_MkdbW4UHI0jWN_T1OattRjXrq_qmzAmOfels670,3165
20
20
  risk/_network/__init__.py,sha256=YrAMfhL0CMWQb3sY-mn1VxK44zZAWeFAvHrBONH9I-A,127
21
- risk/_network/_io.py,sha256=wjy_wkQkRO4sI_U6Xvheu7x_Jd8mXyBnXAhtZSjqJHY,28129
21
+ risk/_network/_io.py,sha256=wmokwNViz24Gv6o3OFRTYHftYYz4sN64VigGrdEGzy8,28057
22
22
  risk/_network/_graph/__init__.py,sha256=SFgxgxUiZK4vvw6bdQ04DSMXEr8xjMaQV-Wne6wAIqM,104
23
23
  risk/_network/_graph/_api.py,sha256=sp3_mLJDP_xQexYBjyM17iyzLb2oGmiC050kcw-jVho,8474
24
24
  risk/_network/_graph/_graph.py,sha256=x2EWT_ZVwxh7m9a01yG4WMdmAxBxiaxX3CvkqP9QAXE,12486
@@ -34,8 +34,8 @@ risk/_network/_plotter/_plotter.py,sha256=F2hw-spUdsXjvuG36o0YFR3Pnd-CZOHYUq4vW0
34
34
  risk/_network/_plotter/_utils/__init__.py,sha256=JXgjKiBWvXx0X2IeFnrOh5YZQGQoELbhJZ0Zh2mFEOo,211
35
35
  risk/_network/_plotter/_utils/_colors.py,sha256=JCliSvz8_-TsjilaRHSEsqdXFBUYlzhXKOSRGdCm9Kw,19177
36
36
  risk/_network/_plotter/_utils/_layout.py,sha256=GyGLc2U1WWUVL1Te9uPi_CLqlW_E4TImXRAL5TeA5D8,3633
37
- risk_network-0.0.14b1.dist-info/licenses/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
38
- risk_network-0.0.14b1.dist-info/METADATA,sha256=82-RZi0eyLscZ5PG64zxheyTSVCb36LkV2GXE7Kmf44,6853
39
- risk_network-0.0.14b1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
- risk_network-0.0.14b1.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
41
- risk_network-0.0.14b1.dist-info/RECORD,,
37
+ risk_network-0.0.14b2.dist-info/licenses/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
38
+ risk_network-0.0.14b2.dist-info/METADATA,sha256=8Ymwky3eLiYB9OMO0kVzfF40uvnD3uFCBmY7q6pfitI,6853
39
+ risk_network-0.0.14b2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
+ risk_network-0.0.14b2.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
41
+ risk_network-0.0.14b2.dist-info/RECORD,,