Skip to content

Commit 28958e3

Browse files
authored
Small optimization to dpp_single (#5)
* Small optimization Calculating cliques and plex overlap is one of the slowest steps in `dpp_single`. This optimization calculates overlap only for those cliques and plexes that are not already merged into a single community. * Bugfix removing unnecessary duplicate calls The `dpp_single` function was called twice per iteration, rather than once due to a typo.
1 parent f850ee4 commit 28958e3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/dpp/dpp_iter.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
% community.
66

77
% reuse previous calculations
8-
if ~exist('cliq1', 'var')
8+
if ~exist('cliq_and_plex1', 'var')
99
[cliq_and_plex1, communities1] = dpp_single(a1, k, m);
1010
end
1111

src/dpp/dpp_single.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@
7777
% remaining cliques/plexes
7878
js = (i+1):num_cliq_and_plex;
7979

80+
% optimization: only consider those that are not already part of the same community
81+
js = js(communities(js) ~= communities(i));
82+
if isempty(js)
83+
continue;
84+
end
85+
8086
% vector of overlaps between remaining cliques/plexes and clique/plex i
8187
overlap = sum(cliq_and_plex(js, cliq_and_plex(i, :)), 2);
8288

0 commit comments

Comments
 (0)