我在给出参数时出现了一个奇怪的行为。我的方法的标题是:
class Acceptability {
public:
Graph* G;
std::unordered_set<node>* community;
std::unordered_set<node>* shell;
public:
Acceptability(Graph& G, std::unordered_set<node>& community,
std::unordered_set<node>& shell);
virtual ~Acceptability();
virtual double getValue(node v) = 0;
};
class NodeClusterSimilarity: public Acceptability {
public:
NodeClusterSimilarity(Graph& G, std::unordered_set<node>& community,
std::unordered_set<node>& shell);
virtual ~NodeClusterSimilarity();
virtual double getValue(node v);
};
这两个类的构造函数如下:
GreedyCommunityExpansion::Acceptability::Acceptability(
Graph& G, std::unordered_set<node>& community,
std::unordered_set<node>& shell) {
this->G = &G;
this->community = &community;
this->shell = &shell;
}
GreedyCommunityExpansion::NodeClusterSimilarity::NodeClusterSimilarity(
Graph& G, std::unordered_set<node>& community,
std::unordered_set<node>& shell)
: Acceptability(G, community, shell) {
}
NodeClusterSimilarity
在测试我的实现时,我使用community {0}
and创建了一个类型的对象shell {1,2,3}
。然后我调用了该方法getValue()
,令人惊讶的是:community
传递参数后的大小是1
(hurraaaaaaas !!!)但大小shell
是0
:(([预期值显然是3
]
谁能告诉我,怎么了?