本文整理汇总了C++中DistanceMatrix::asMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ DistanceMatrix::asMatrix方法的具体用法?C++ DistanceMatrix::asMatrix怎么用?C++ DistanceMatrix::asMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DistanceMatrix
的用法示例。
在下文中一共展示了DistanceMatrix::asMatrix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: midpointRooting
void TreeTools::midpointRooting(Tree& tree)
{
throw Exception("TreeTools::midpointRooting(Tree). This function is deprecated, use TreeTemplateTools::midRoot instead!");
if (tree.isRooted())
tree.unroot();
DistanceMatrix* dist = getDistanceMatrix(tree);
vector<size_t> pos = MatrixTools::whichMax(dist->asMatrix());
double dmid = (*dist)(pos[0], pos[1]) / 2;
int id1 = tree.getLeafId(dist->getName(pos[0]));
int id2 = tree.getLeafId(dist->getName(pos[1]));
int rootId = tree.getRootId();
double d1 = getDistanceBetweenAnyTwoNodes(tree, id1, rootId);
double d2 = getDistanceBetweenAnyTwoNodes(tree, id2, rootId);
int current = d2 > d1 ? id2 : id1;
delete dist;
double l = tree.getDistanceToFather(current);
double c = l;
while (c < dmid)
{
current = tree.getFatherId(current);
l = tree.getDistanceToFather(current);
c += l;
}
tree.newOutGroup(current);
int brother = tree.getSonsId(tree.getRootId())[1];
if (brother == current)
brother = tree.getSonsId(tree.getRootId())[0];
tree.setDistanceToFather(current, l - (c - dmid));
tree.setDistanceToFather(brother, c - dmid);
}