bpp-core3  3.0.0
TreeGraph.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_GRAPH_TREEGRAPH_H
6 #define BPP_GRAPH_TREEGRAPH_H
7 
8 #include <iostream>
9 #include <ostream>
10 #include <string>
11 #include <vector>
12 
13 #include "../Exceptions.h"
14 #include "../Numeric/VectorTools.h"
15 #include "Graph.h"
16 
17 namespace bpp
18 {
19 class TreeGraph :
20  public virtual Graph
21 {
22 public:
27  virtual bool isValid() const = 0;
28 
34  virtual Graph::NodeId getFatherOfNode(Graph::NodeId nodeid) const = 0;
35 
41  virtual Graph::EdgeId getEdgeToFather(Graph::NodeId node) const = 0;
42 
47  virtual bool hasFather(Graph::NodeId node) const = 0;
48 
53  virtual bool isLeaf(Graph::NodeId node) const = 0;
54 
61  virtual std::vector<Graph::NodeId> getLeavesUnderNode(Graph::NodeId node) const = 0;
62 
67  virtual std::vector<Graph::NodeId> getSons(Graph::NodeId node) const = 0;
68 
73  virtual std::vector<Graph::EdgeId> getBranches(Graph::NodeId node) const = 0;
74 
79  virtual std::unique_ptr<Graph::NodeIterator> sonsIterator(Graph::NodeId node) = 0;
80 
81  virtual std::unique_ptr<Graph::NodeIterator> sonsIterator(Graph::NodeId node) const = 0;
82 
87  virtual std::unique_ptr<Graph::EdgeIterator> branchesIterator(Graph::NodeId node) = 0;
88 
89  virtual std::unique_ptr<Graph::EdgeIterator> branchesIterator(Graph::NodeId node) const = 0;
90 
95  virtual size_t getNumberOfSons(Graph::NodeId node) const = 0;
96 
101  virtual void setFather(Graph::NodeId node, Graph::NodeId fatherNode) = 0;
102 
103  virtual void setFather(Graph::NodeId node, Graph::NodeId fatherNode, Graph::EdgeId edgeId) = 0;
104 
109  virtual void addSon(Graph::NodeId node, Graph::NodeId sonNode) = 0;
110 
111  virtual void addSon(Graph::NodeId node, Graph::NodeId sonNode, Graph::EdgeId edgeId) = 0;
112 
117  std::vector<Graph::NodeId> removeSons(Graph::NodeId node);
118 
123  virtual void removeSon(Graph::NodeId node, Graph::NodeId son) = 0;
124 
129  virtual void rootAt(Graph::NodeId newRoot) = 0;
130 
137  virtual void unRoot(bool joinRootSons) = 0;
138 
144  virtual void setOutGroup(Graph::NodeId newOutGroup) = 0;
145 
150  virtual std::vector<Graph::NodeId> getSubtreeNodes(Graph::NodeId localRoot) const = 0;
151 
156  virtual std::vector<Graph::EdgeId> getSubtreeEdges(Graph::NodeId localRoot) const = 0;
157 
158  // ///FROM TREETOOLS & TREETOOLS COMPAT
159 
160 
161  virtual std::vector<Graph::NodeId> getNodePathBetweenTwoNodes(Graph::NodeId nodeA, Graph::NodeId nodeB, bool includeAncestor = true) const = 0;
162 
163  virtual std::vector<Graph::EdgeId> getEdgePathBetweenTwoNodes(Graph::NodeId nodeA, Graph::NodeId nodeB) const = 0;
164 
165  /*
166  * @bref Compute the MRCA of the gven nodes
167  *
168  */
169 
170  virtual Graph::NodeId MRCA(const std::vector<Graph::NodeId>& nodes) const = 0;
171 };
172 }
173 #endif // BPP_GRAPH_TREEGRAPH_H
std::vector< Graph::NodeId > removeSons(Graph::NodeId node)
virtual void rootAt(Graph::NodeId newRoot)=0
virtual Graph::NodeId MRCA(const std::vector< Graph::NodeId > &nodes) const =0
virtual std::vector< Graph::NodeId > getNodePathBetweenTwoNodes(Graph::NodeId nodeA, Graph::NodeId nodeB, bool includeAncestor=true) const =0
virtual bool isValid() const =0
virtual bool isLeaf(Graph::NodeId node) const =0
virtual void unRoot(bool joinRootSons)=0
virtual void setOutGroup(Graph::NodeId newOutGroup)=0
virtual std::vector< Graph::NodeId > getSons(Graph::NodeId node) const =0
unsigned int NodeId
Definition: Graph.h:30
virtual size_t getNumberOfSons(Graph::NodeId node) const =0
Get the number of sons node.
virtual bool hasFather(Graph::NodeId node) const =0
virtual std::unique_ptr< Graph::EdgeIterator > branchesIterator(Graph::NodeId node)=0
virtual void setFather(Graph::NodeId node, Graph::NodeId fatherNode)=0
virtual std::vector< Graph::EdgeId > getEdgePathBetweenTwoNodes(Graph::NodeId nodeA, Graph::NodeId nodeB) const =0
virtual std::vector< Graph::EdgeId > getBranches(Graph::NodeId node) const =0
virtual std::vector< Graph::NodeId > getLeavesUnderNode(Graph::NodeId node) const =0
virtual Graph::EdgeId getEdgeToFather(Graph::NodeId node) const =0
virtual std::vector< Graph::EdgeId > getSubtreeEdges(Graph::NodeId localRoot) const =0
virtual std::unique_ptr< Graph::NodeIterator > sonsIterator(Graph::NodeId node)=0
virtual Graph::NodeId getFatherOfNode(Graph::NodeId nodeid) const =0
virtual std::vector< Graph::NodeId > getSubtreeNodes(Graph::NodeId localRoot) const =0
virtual void addSon(Graph::NodeId node, Graph::NodeId sonNode)=0
virtual void removeSon(Graph::NodeId node, Graph::NodeId son)=0
unsigned int EdgeId
Definition: Graph.h:31