Skip to content

Commit

Permalink
Notifications refined, docs and shared code updated (nodes number est…
Browse files Browse the repository at this point in the history
…imation fixed)
  • Loading branch information
luav committed Feb 22, 2017
1 parent 702a670 commit 64076b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions onmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ template <typename NodeId>
using Grouping = vector< set< NodeId > >;

template <typename NodeId>
struct NodeToGroup : public
unordered_map< NodeId, set<int> >
struct NodeToGroup : public unordered_map< NodeId, set<int> >
{
int sharedGroups(const NodeId n_, const NodeId m_) const {
// PP2(n_,m_);
Expand Down Expand Up @@ -122,7 +121,7 @@ struct NodeToGroup : public
};

struct OverlapMatrix {
map< pair<int,int> , int> om; // the pair is an ordered pair.
map< pair<int,int> , int> om; // the pair is an ordered pair; count
int N;

OverlapMatrix(): om(), N(0) {}
Expand Down Expand Up @@ -156,6 +155,7 @@ Grouping<NodeId> fileToSet(const char *fname, float membership=1.f
size_t clsnum = 0; // The number of clusters
size_t ndsnum = 0; // The number of nodes
parseHeader(input, line, clsnum, ndsnum);
const bool estimNodes = ndsnum; // The number of nodes is estimated
const size_t cmsbytes = ndsnum ? 0 : inputSize(input, fname);
if(!ndsnum || !clsnum)
estimateSizes(ndsnum, clsnum, cmsbytes, membership);
Expand Down Expand Up @@ -209,7 +209,7 @@ Grouping<NodeId> fileToSet(const char *fname, float membership=1.f
ss.shrink_to_fit(); // Trim preallocated space for the clusters

if(ndsnum && mbscnt != ndsnum) {
if(mbscnt < ndsnum)
if(!estimNodes && mbscnt < ndsnum)
fprintf(stderr, "WARNING, Specification number of nodes is incorrect (specified: %lu"
") in the header of '%s'. The actual number of members: %lu\n", ndsnum, fname, mbscnt);
else printf("# Average membership in '%s': %.4G\n", fname, float(mbscnt) / ndsnum);
Expand Down
3 changes: 2 additions & 1 deletion shared/cnl_header_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ bool estimateSizes(size_t& ndsnum, size_t& clsnum, size_t cmsbytes, float member

if(clsnum && !ndsnum) {
// Typically the number of nodes is at least square of the number of clusters
ndsnum = clsnum * clsnum / membership;
// Note: optimistic estimate to not overuse the memory
ndsnum = 2 * clsnum; // clsnum * clsnum / membership;
return true;
}

Expand Down

0 comments on commit 64076b3

Please sign in to comment.