bpp-core3  3.0.0
AssociationTreeGraphObserver.h
Go to the documentation of this file.
1 //
2 // File: AssociationTreeGraphObserver.h
3 // Authors:
4 // Thomas Bigot
5 // Last modified: vendredi 4 novembre 2016, à 10h 21
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_ASSOCIATIONTREEGRAPHOBSERVER_H
42 #define BPP_GRAPH_ASSOCIATIONTREEGRAPHOBSERVER_H
43 
44 #include <iostream>
45 #include <map>
46 #include <memory>
47 #include <ostream>
48 #include <vector>
49 
51 #include "TreeGraph.h"
52 
53 namespace bpp
54 {
62 template<class N, class E>
64  public virtual AssociationGraphObserver<N, E>
65 {
66 public:
69 
70  typedef typename TreeGraph::NodeId NodeGraphid;
71  typedef typename TreeGraph::EdgeId EdgeGraphid;
72 
73 public:
79  virtual bool isValid() const = 0;
80 
87  virtual std::shared_ptr<E> getEdgeToFather(const std::shared_ptr<N> nodeObject) const = 0;
88 
89  virtual std::shared_ptr<E> getEdgeToFather(const NodeIndex nodeIndex) const = 0;
90 
96  virtual void rootAt(const std::shared_ptr<N> root) = 0;
97 
98  /*
99  * @brief check if rooted, ie directed
100  *
101  */
102 
103  virtual bool isRooted() const = 0;
104 
111  virtual std::shared_ptr<N> getFatherOfNode(const std::shared_ptr<N> nodeObject) const = 0;
112 
117  virtual bool hasFather(const std::shared_ptr<N> nodeObject) const = 0;
118  virtual bool hasFather(const NodeIndex node) const = 0;
119 
126  virtual std::vector<std::shared_ptr<N> > getSons(const std::shared_ptr<N> node) const = 0;
127 
128  virtual std::vector<NodeIndex> getSons(const NodeIndex node) const = 0;
129 
136  virtual std::vector<std::shared_ptr<E> > getBranches(const std::shared_ptr<N> node) const = 0;
137 
138  virtual std::vector<EdgeIndex> getBranches(const NodeIndex node) const = 0;
139 
146  virtual std::shared_ptr<N> getSon(const std::shared_ptr<E> edge) const = 0;
147  virtual NodeIndex getSon(const EdgeIndex edge) const = 0;
148 
155  virtual std::shared_ptr<N> getFatherOfEdge(const std::shared_ptr<E> edge) const = 0;
156  virtual NodeIndex getFatherOfEdge(const EdgeIndex edge) const = 0;
157 
164  virtual size_t getNumberOfSons(const std::shared_ptr<N> node) const = 0;
165 
173  virtual std::vector<std::shared_ptr<N> > getLeavesUnderNode(std::shared_ptr<N> node) const = 0;
174 
180  virtual std::vector<std::shared_ptr<N> > removeSons(const std::shared_ptr<N> node) = 0;
181 
186  virtual void removeSon(const std::shared_ptr<N> node, const std::shared_ptr<N> son) = 0;
187 
196  virtual void setFather(const std::shared_ptr<N> nodeObject, const std::shared_ptr<N> fatherNodeObject, const std::shared_ptr<E> edgeObject = 0) = 0;
197 
206  virtual void addSon(const std::shared_ptr<N> nodeObject, const std::shared_ptr<N> sonNodeObject, const std::shared_ptr<E> edgeObject = 0) = 0;
207 
213  /*
214  * @brief builds iterator on the neighbor nodes of a Node
215  *
216  */
217 
220 
221 
222  /*
223  * @brief builds iterator on the sons of a Node
224  *
225  */
226 
227  virtual std::unique_ptr<NodeIterator> sonsIterator(std::shared_ptr<N> node) = 0;
228 
229  virtual std::unique_ptr<NodeIterator> sonsIterator(std::shared_ptr<N> node) const = 0;
230 
231  /*
232  * @brief builds iterator on the branches to sons of a Node
233  *
234  */
235 
236  virtual std::unique_ptr<EdgeIterator> branchesIterator(std::shared_ptr<N> node) = 0;
237 
238  virtual std::unique_ptr<EdgeIterator> branchesIterator(std::shared_ptr<N> node) const = 0;
239 
250  virtual std::vector<std::shared_ptr<N> > getNodePathBetweenTwoNodes(const std::shared_ptr<N> nodeA, const std::shared_ptr<N> nodeB, bool includeAncestor = true) const = 0;
251 
252  virtual std::vector<std::shared_ptr<E> > getEdgePathBetweenTwoNodes(const std::shared_ptr<N> nodeA, const std::shared_ptr<N> nodeB) const = 0;
253 
254  virtual std::vector<std::shared_ptr<N> > getSubtreeNodes(const std::shared_ptr<N> localRoot) const = 0;
255 
256  virtual std::vector<std::shared_ptr<E> > getSubtreeEdges(const std::shared_ptr<N> localRoot) const = 0;
257 };
258 }
259 #endif // BPP_GRAPH_ASSOCIATIONTREEGRAPHOBSERVER_H
Defines a Graph Associator. It is a template which follows (subscribed to) a Graph.
Defines a Tree Graph Associator. It is a template which follows (subscribed to) a Graph.
virtual bool hasFather(const NodeIndex node) const =0
virtual std::vector< NodeIndex > getSons(const NodeIndex node) const =0
virtual std::vector< std::shared_ptr< E > > getEdgePathBetweenTwoNodes(const std::shared_ptr< N > nodeA, const std::shared_ptr< N > nodeB) const =0
virtual size_t getNumberOfSons(const std::shared_ptr< N > node) const =0
virtual std::vector< std::shared_ptr< N > > getLeavesUnderNode(std::shared_ptr< N > node) const =0
virtual std::vector< std::shared_ptr< N > > getSons(const std::shared_ptr< N > node) const =0
virtual std::unique_ptr< EdgeIterator > branchesIterator(std::shared_ptr< N > node) const =0
virtual std::vector< std::shared_ptr< E > > getBranches(const std::shared_ptr< N > node) const =0
AssociationTreeGraphObserver< N, E >::NodeIndex NodeIndex
virtual void addSon(const std::shared_ptr< N > nodeObject, const std::shared_ptr< N > sonNodeObject, const std::shared_ptr< E > edgeObject=0)=0
AssociationGraphObserver< N, E >::EdgeIterator EdgeIterator
AssociationTreeGraphObserver< N, E >::EdgeIndex EdgeIndex
virtual bool hasFather(const std::shared_ptr< N > nodeObject) const =0
virtual std::shared_ptr< N > getSon(const std::shared_ptr< E > edge) const =0
virtual std::shared_ptr< N > getFatherOfEdge(const std::shared_ptr< E > edge) const =0
virtual std::vector< std::shared_ptr< N > > getNodePathBetweenTwoNodes(const std::shared_ptr< N > nodeA, const std::shared_ptr< N > nodeB, bool includeAncestor=true) const =0
Get a vector of ancestor nodes between to nodes.
virtual void removeSon(const std::shared_ptr< N > node, const std::shared_ptr< N > son)=0
AssociationGraphObserver< N, E >::NodeIterator NodeIterator
virtual std::vector< std::shared_ptr< E > > getSubtreeEdges(const std::shared_ptr< N > localRoot) const =0
virtual NodeIndex getSon(const EdgeIndex edge) const =0
virtual bool isValid() const =0
virtual std::shared_ptr< E > getEdgeToFather(const std::shared_ptr< N > nodeObject) const =0
virtual std::shared_ptr< E > getEdgeToFather(const NodeIndex nodeIndex) const =0
virtual std::vector< std::shared_ptr< N > > removeSons(const std::shared_ptr< N > node)=0
virtual void setFather(const std::shared_ptr< N > nodeObject, const std::shared_ptr< N > fatherNodeObject, const std::shared_ptr< E > edgeObject=0)=0
virtual std::vector< EdgeIndex > getBranches(const NodeIndex node) const =0
virtual std::unique_ptr< NodeIterator > sonsIterator(std::shared_ptr< N > node)=0
virtual std::shared_ptr< N > getFatherOfNode(const std::shared_ptr< N > nodeObject) const =0
virtual std::vector< std::shared_ptr< N > > getSubtreeNodes(const std::shared_ptr< N > localRoot) const =0
virtual void rootAt(const std::shared_ptr< N > root)=0
Sets the root and make the tree directed from root to leaves.
virtual std::unique_ptr< NodeIterator > sonsIterator(std::shared_ptr< N > node) const =0
virtual bool isRooted() const =0
virtual std::unique_ptr< EdgeIterator > branchesIterator(std::shared_ptr< N > node)=0
virtual NodeIndex getFatherOfEdge(const EdgeIndex edge) const =0
unsigned int NodeId
Definition: Graph.h:66
unsigned int EdgeId
Definition: Graph.h:67