bpp-core3  3.0.0
TreeGraph.h
Go to the documentation of this file.
1 //
2 // File: TreeGraph.h
3 // Authors:
4 // Thomas Bigot
5 // Last modified: vendredi 4 novembre 2016, à 10h 25
6 //
7 
8 /*
9  Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
10 
11  This software is a computer program whose purpose is to provide utilitary
12  classes. This file belongs to the Bio++ Project.
13 
14  This software is governed by the CeCILL license under French law and
15  abiding by the rules of distribution of free software. You can use,
16  modify and/ or redistribute the software under the terms of the CeCILL
17  license as circulated by CEA, CNRS and INRIA at the following URL
18  "http://www.cecill.info".
19 
20  As a counterpart to the access to the source code and rights to copy,
21  modify and redistribute granted by the license, users are provided only
22  with a limited warranty and the software's author, the holder of the
23  economic rights, and the successive licensors have only limited
24  liability.
25 
26  In this respect, the user's attention is drawn to the risks associated
27  with loading, using, modifying and/or developing or reproducing the
28  software by the user in light of its specific status of free software,
29  that may mean that it is complicated to manipulate, and that also
30  therefore means that it is reserved for developers and experienced
31  professionals having in-depth computer knowledge. Users are therefore
32  encouraged to load and test the software's suitability as regards their
33  requirements in conditions enabling the security of their systems and/or
34  data to be ensured and, more generally, to use and operate it in the
35  same conditions as regards security.
36 
37  The fact that you are presently reading this means that you have had
38  knowledge of the CeCILL license and that you accept its terms.
39 */
40 
41 #ifndef BPP_GRAPH_TREEGRAPH_H
42 #define BPP_GRAPH_TREEGRAPH_H
43 
44 #include <iostream>
45 #include <ostream>
46 #include <string>
47 #include <vector>
48 
49 #include "../Exceptions.h"
50 #include "../Numeric/VectorTools.h"
51 #include "Graph.h"
52 
53 namespace bpp
54 {
55 class TreeGraph :
56  public virtual Graph
57 {
58 public:
63  virtual bool isValid() const = 0;
64 
70  virtual Graph::NodeId getFatherOfNode(Graph::NodeId nodeid) const = 0;
71 
77  virtual Graph::EdgeId getEdgeToFather(Graph::NodeId node) const = 0;
78 
83  virtual bool hasFather(Graph::NodeId node) const = 0;
84 
89  virtual bool isLeaf(Graph::NodeId node) const = 0;
90 
97  virtual std::vector<Graph::NodeId> getLeavesUnderNode(Graph::NodeId node) const = 0;
98 
103  virtual std::vector<Graph::NodeId> getSons(Graph::NodeId node) const = 0;
104 
109  virtual std::vector<Graph::EdgeId> getBranches(Graph::NodeId node) const = 0;
110 
115  virtual std::unique_ptr<Graph::NodeIterator> sonsIterator(Graph::NodeId node) = 0;
116 
117  virtual std::unique_ptr<Graph::NodeIterator> sonsIterator(Graph::NodeId node) const = 0;
118 
123  virtual std::unique_ptr<Graph::EdgeIterator> branchesIterator(Graph::NodeId node) = 0;
124 
125  virtual std::unique_ptr<Graph::EdgeIterator> branchesIterator(Graph::NodeId node) const = 0;
126 
131  virtual size_t getNumberOfSons(Graph::NodeId node) const = 0;
132 
137  virtual void setFather(Graph::NodeId node, Graph::NodeId fatherNode) = 0;
138 
139  virtual void setFather(Graph::NodeId node, Graph::NodeId fatherNode, Graph::EdgeId edgeId) = 0;
140 
145  virtual void addSon(Graph::NodeId node, Graph::NodeId sonNode) = 0;
146 
147  virtual void addSon(Graph::NodeId node, Graph::NodeId sonNode, Graph::EdgeId edgeId) = 0;
148 
153  std::vector<Graph::NodeId> removeSons(Graph::NodeId node);
154 
159  virtual void removeSon(Graph::NodeId node, Graph::NodeId son) = 0;
160 
165  virtual void rootAt(Graph::NodeId newRoot) = 0;
166 
173  virtual void unRoot(bool joinRootSons) = 0;
174 
180  virtual void setOutGroup(Graph::NodeId newOutGroup) = 0;
181 
186  virtual std::vector<Graph::NodeId> getSubtreeNodes(Graph::NodeId localRoot) const = 0;
187 
192  virtual std::vector<Graph::EdgeId> getSubtreeEdges(Graph::NodeId localRoot) const = 0;
193 
194  // ///FROM TREETOOLS & TREETOOLS COMPAT
195 
196 
197  virtual std::vector<Graph::NodeId> getNodePathBetweenTwoNodes(Graph::NodeId nodeA, Graph::NodeId nodeB, bool includeAncestor = true) const = 0;
198 
199  virtual std::vector<Graph::EdgeId> getEdgePathBetweenTwoNodes(Graph::NodeId nodeA, Graph::NodeId nodeB) const = 0;
200 
201  /*
202  * @bref Compute the MRCA of the gven nodes
203  *
204  */
205 
206  virtual Graph::NodeId MRCA(const std::vector<Graph::NodeId>& nodes) const = 0;
207 };
208 }
209 #endif // BPP_GRAPH_TREEGRAPH_H
unsigned int NodeId
Definition: Graph.h:66
unsigned int EdgeId
Definition: Graph.h:67
virtual std::vector< Graph::NodeId > getSubtreeNodes(Graph::NodeId localRoot) const =0
virtual std::vector< Graph::NodeId > getLeavesUnderNode(Graph::NodeId node) const =0
virtual std::vector< Graph::EdgeId > getBranches(Graph::NodeId node) const =0
virtual void unRoot(bool joinRootSons)=0
virtual void setFather(Graph::NodeId node, Graph::NodeId fatherNode)=0
virtual void setOutGroup(Graph::NodeId newOutGroup)=0
virtual std::vector< Graph::NodeId > getSons(Graph::NodeId node) const =0
virtual bool isLeaf(Graph::NodeId node) const =0
virtual std::vector< Graph::EdgeId > getSubtreeEdges(Graph::NodeId localRoot) const =0
virtual std::unique_ptr< Graph::EdgeIterator > branchesIterator(Graph::NodeId node)=0
virtual std::unique_ptr< Graph::NodeIterator > sonsIterator(Graph::NodeId node) const =0
virtual Graph::NodeId MRCA(const std::vector< Graph::NodeId > &nodes) const =0
virtual size_t getNumberOfSons(Graph::NodeId node) const =0
Get the number of sons node.
virtual void addSon(Graph::NodeId node, Graph::NodeId sonNode, Graph::EdgeId edgeId)=0
virtual std::unique_ptr< Graph::EdgeIterator > branchesIterator(Graph::NodeId node) 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 > getNodePathBetweenTwoNodes(Graph::NodeId nodeA, Graph::NodeId nodeB, bool includeAncestor=true) const =0
virtual bool hasFather(Graph::NodeId node) const =0
virtual bool isValid() const =0
virtual void rootAt(Graph::NodeId newRoot)=0
virtual void addSon(Graph::NodeId node, Graph::NodeId sonNode)=0
virtual void setFather(Graph::NodeId node, Graph::NodeId fatherNode, Graph::EdgeId edgeId)=0
virtual std::vector< Graph::EdgeId > getEdgePathBetweenTwoNodes(Graph::NodeId nodeA, Graph::NodeId nodeB) const =0
virtual Graph::EdgeId getEdgeToFather(Graph::NodeId node) const =0
std::vector< Graph::NodeId > removeSons(Graph::NodeId node)
virtual void removeSon(Graph::NodeId node, Graph::NodeId son)=0