Skip to content

Commit

Permalink
Update abcd.py
Browse files Browse the repository at this point in the history
added empirical_xi and degree_sequence properties to Graph object
  • Loading branch information
JordanBarrett95 authored Jul 11, 2024
1 parent f0644b4 commit 0f97f13
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/abcd_graph/abcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,25 @@ def to_edge_list(self) -> NDArray[np.int64]:
assert self._graph is not None

return np.array(self._graph.edges).reshape(-1, 2)

#The empirical xi is the fraction of background edges to total edges
@property
@require_graph_built
def empirical_xi(self) -> float:
assert self._graph is not None

num_edges = len(self._graph.edges)
num_community_edges = sum(len(community.edges) for community in self._graph.communities)
return 1-(num_community_edges/num_edges)

#This should be the same as self._graph.deg_b + self._graph.deg_c
@property
@require_graph_built
def degree_sequence(self) -> dict[int, int]:
assert self._graph is not None

deg = {v: 0 for v in range(self.n)}
for e in self._graph.edges:
deg[e[0]] += 1
deg[e[1]] += 1
return deg

1 comment on commit 0f97f13

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/abcd_graph
   abcd.py1444569%56–60, 85–87, 120, 128–134, 139–142, 147–155, 161–177, 181–182, 248–252, 258–264
   logger.py53983%39, 43, 47, 51, 55, 63, 66, 69, 72
   utils.py29776%36, 43–44, 51–54
   version.py330%20–24
src/abcd_graph/core
   build.py89397%132, 149, 161
   models.py155299%53, 149
   utils.py22864%31, 45–55
TOTAL5747787% 

Tests Skipped Failures Errors Time
42 0 💤 0 ❌ 0 🔥 23.607s ⏱️

Please sign in to comment.