14 throw Exception(
"BackwardLikelihoodTree::makeBackwardLikelihoodAtEdge: forwardTree_ is missing.");
17 auto fatherIndex =
forwardTree_->getFatherOfEdge(edgeIndex);
21 auto backNode =
hasNode(fatherIndex)
25 auto fatherNode =
forwardTree_->getProcessTree()->getNode(fatherIndex);
29 if (fatherNode->isSpeciation())
32 auto edgeIds =
forwardTree_->getOutgoingEdges(fatherIndex);
35 for (
auto eId : edgeIds)
40 deps.push_back(backNode);
44 else if (fatherNode->isMixture())
46 backwardEdge = backNode;
49 throw Exception(
"BackwardLikelihoodTree::makeBackwardLikelihoodAtEdge : event not recognized for node " +
TextTools::toString(fatherNode->getSpeciesIndex()));
65 throw Exception(
"BackwardLikelihoodTree::makeBackwardLikelihoodAtNode: forwardTree_ is missing.");
73 const auto edgesIndexes =
forwardTree_->getIncomingEdges(nodeIndex);
79 for (
const auto& edgeIndex:edgesIndexes)
81 auto backEdge =
hasEdge(edgeIndex)
87 const auto processEdge =
forwardTree_->getProcessTree()->getEdge(edgeIndex);
89 const auto brprob = processEdge->getProba();
93 if (processEdge->getBrLen())
95 auto transitionMatrix = processEdge->getTransitionMatrix();
105 throw Exception(
"BackwardLikelihoodTree::makeBackwardLikelihoodAtNode : missing information on edge " +
TextTools::toString(processEdge->getSpeciesIndex()));
107 if (edgesIndexes.size() == 1)
109 backwardNode = backLikeEdge;
113 deps.push_back(backLikeEdge);
AssociationGraphObserver< N, E >::EdgeIndex EdgeIndex
AssociationGraphObserver< N, E >::NodeIndex NodeIndex
virtual std::shared_ptr< N > getNode(NodeIndex nodeIndex) const=0
virtual NodeIndex setNodeIndex(const std::shared_ptr< N > nodeObject, NodeIndex index)=0
virtual void associateNode(std::shared_ptr< N > nodeObject, NodeGraphid node)=0
virtual EdgeIndex setEdgeIndex(const std::shared_ptr< E > edgeObject, EdgeIndex index)=0
virtual bool hasNode(NodeIndex nodeIndex) const=0
virtual std::shared_ptr< E > getEdge(EdgeIndex edgeIndex) const=0
virtual bool hasEdge(EdgeIndex edgeIndex) const=0
virtual void associateEdge(std::shared_ptr< E > edgeObject, EdgeGraphid edge)=0
std::shared_ptr< ForwardLikelihoodTree > forwardTree_
BackwardLikelihoodAboveRef makeBackwardLikelihoodAtEdge(PhyloTree::EdgeIndex index)
ValueRef< Eigen::RowVectorXd > rFreqs_
ConditionalLikelihoodRef setRootFrequencies(const ValueRef< Eigen::RowVectorXd > rootFreqs)
ConditionalLikelihoodRef makeBackwardLikelihoodAtNode(PhyloTree::NodeIndex index)
MatrixDimension likelihoodMatrixDim_
static ValueRef< R > create(Context &c, NodeRefVec &&deps, const Dimension< R > &dim)
Build a new CWiseAdd node with the given output dimensions.
static ValueRef< R > create(Context &c, NodeRefVec &&deps, const Dimension< R > &dim)
Build a new MatrixProduct node with the given output dimensions.
std::string toString(T t)
Defines the basic types of data flow nodes.
ValueRef< MatrixLik > ConditionalLikelihoodRef
std::vector< NodeRef > NodeRefVec
Alias for a dependency vector (of NodeRef).
ValueRef< MatrixLik > BackwardLikelihoodAboveRef