bpp-core3  3.0.0
AssociationDAGraphObserver.h
Go to the documentation of this file.
1 //
2 // File: AssociationDAGraphObserver.h
3 // Authors:
4 // Laurent Guéguen
5 // Last modified: lundi 19 décembre 2016, à 21h 48
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_ASSOCIATIONDAGRAPHOBSERVER_H
42 #define BPP_GRAPH_ASSOCIATIONDAGRAPHOBSERVER_H
43 
44 #include <iostream>
45 #include <map>
46 #include <memory>
47 #include <ostream>
48 #include <vector>
49 
51 #include "DAGraph.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 DAGraph::NodeId NodeGraphid;
71  typedef typename DAGraph::EdgeId EdgeGraphid;
72 
73 public:
79  virtual bool isValid() const = 0;
80 
86  virtual bool isRooted() const = 0;
87 
94  virtual void rootAt(const std::shared_ptr<N> root) = 0;
95 
96 
103  virtual std::vector<std::shared_ptr<N> > getFathers(const std::shared_ptr<N> node) const = 0;
104 
105  virtual std::vector<NodeIndex> getFathers(const NodeIndex node) const = 0;
106 
111  virtual bool hasFather(const std::shared_ptr<N> nodeObject) const = 0;
112  virtual bool hasFather(const NodeIndex node) const = 0;
113 
120  virtual std::vector<std::shared_ptr<N> > getSons(const std::shared_ptr<N> node) const = 0;
121 
122  virtual std::vector<NodeIndex> getSons(const NodeIndex node) const = 0;
123 
130  virtual std::shared_ptr<N> getSon(const std::shared_ptr<E> edge) const = 0;
131  virtual NodeIndex getSon(const EdgeIndex edge) const = 0;
132 
139  virtual std::shared_ptr<N> getFatherOfEdge(const std::shared_ptr<E> edge) const = 0;
140  virtual NodeIndex getFatherOfEdge(const EdgeIndex edge) const = 0;
141 
148  virtual size_t getNumberOfSons(const std::shared_ptr<N> node) const = 0;
149 
156  virtual size_t getNumberOfFathers(const std::shared_ptr<N> node) const = 0;
157 
165  virtual std::vector<std::shared_ptr<N> > getLeavesUnderNode(std::shared_ptr<N> node) const = 0;
166 
172  virtual std::vector<std::shared_ptr<N> > removeSons(const std::shared_ptr<N> node) = 0;
173 
180  virtual void removeSon(const std::shared_ptr<N> node, const std::shared_ptr<N> son) = 0;
181 
190  virtual void addSon(const std::shared_ptr<N> nodeObject, const std::shared_ptr<N> sonNodeObject, const std::shared_ptr<E> edgeObject = 0) = 0;
191 
197  virtual std::vector<std::shared_ptr<N> > removeFathers(const std::shared_ptr<N> node) = 0;
198 
203  virtual void removeFather(const std::shared_ptr<N> node, const std::shared_ptr<N> father) = 0;
204 
213  virtual void addFather(const std::shared_ptr<N> nodeObject, const std::shared_ptr<N> fatherNodeObject, const std::shared_ptr<E> edgeObject = 0) = 0;
214 
220  /*
221  * @brief builds iterator on the neighbor nodes of a Node
222  *
223  */
224 
227 
228 
229  /*
230  * @brief builds iterator on the sons of a Node
231  *
232  */
233 
234  virtual std::unique_ptr<NodeIterator> sonsIterator(std::shared_ptr<N> node) = 0;
235 
236  virtual std::unique_ptr<NodeIterator> sonsIterator(std::shared_ptr<N> node) const = 0;
237 
238  /*
239  * @brief builds iterator on the fathers of a Node
240  *
241  */
242 
243  virtual std::unique_ptr<NodeIterator> fathersIterator(std::shared_ptr<N> node) = 0;
244 
245  virtual std::unique_ptr<NodeIterator> fathersIterator(std::shared_ptr<N> node) const = 0;
246 
255  virtual std::vector<std::shared_ptr<N> > getBelowNodes(const std::shared_ptr<N> localRoot) = 0;
256 
257  virtual std::vector<std::shared_ptr<E> > getBelowEdges(const std::shared_ptr<N> localRoot) = 0;
258 };
259 }
260 #endif // BPP_GRAPH_ASSOCIATIONDAGRAPHOBSERVER_H
Defines a DA Graph Associator. It is a template which follows (subscribed to) a Graph.
virtual std::unique_ptr< NodeIterator > sonsIterator(std::shared_ptr< N > node)=0
virtual void addFather(const std::shared_ptr< N > nodeObject, const std::shared_ptr< N > fatherNodeObject, const std::shared_ptr< E > edgeObject=0)=0
AssociationGraphObserver< N, E >::EdgeIterator EdgeIterator
virtual std::vector< NodeIndex > getSons(const NodeIndex node) const =0
virtual std::vector< std::shared_ptr< N > > getFathers(const std::shared_ptr< N > node) const =0
virtual std::vector< std::shared_ptr< E > > getBelowEdges(const std::shared_ptr< N > localRoot)=0
virtual std::vector< std::shared_ptr< N > > removeFathers(const std::shared_ptr< N > node)=0
virtual void addSon(const std::shared_ptr< N > nodeObject, const std::shared_ptr< N > sonNodeObject, const std::shared_ptr< E > edgeObject=0)=0
AssociationDAGraphObserver< N, E >::EdgeIndex EdgeIndex
virtual std::unique_ptr< NodeIterator > fathersIterator(std::shared_ptr< N > node) const =0
virtual void removeSon(const std::shared_ptr< N > node, const std::shared_ptr< N > son)=0
AssociationDAGraphObserver< N, E >::NodeIndex NodeIndex
virtual void removeFather(const std::shared_ptr< N > node, const std::shared_ptr< N > father)=0
virtual bool isValid() const =0
virtual std::vector< std::shared_ptr< N > > getLeavesUnderNode(std::shared_ptr< N > node) const =0
virtual NodeIndex getFatherOfEdge(const EdgeIndex edge) const =0
virtual NodeIndex getSon(const EdgeIndex edge) const =0
virtual std::vector< std::shared_ptr< N > > getBelowNodes(const std::shared_ptr< N > localRoot)=0
Get Below Objects.
virtual std::vector< NodeIndex > getFathers(const NodeIndex node) const =0
virtual size_t getNumberOfFathers(const std::shared_ptr< N > node) const =0
virtual std::vector< std::shared_ptr< N > > removeSons(const std::shared_ptr< N > node)=0
virtual std::shared_ptr< N > getFatherOfEdge(const std::shared_ptr< E > edge) const =0
virtual void rootAt(const std::shared_ptr< N > root)=0
Sets the root and make the DAG directed from root to leaves.
virtual std::unique_ptr< NodeIterator > fathersIterator(std::shared_ptr< N > node)=0
virtual bool hasFather(const NodeIndex node) const =0
virtual bool isRooted() const =0
virtual size_t getNumberOfSons(const std::shared_ptr< N > node) const =0
virtual std::shared_ptr< N > getSon(const std::shared_ptr< E > edge) const =0
virtual std::vector< std::shared_ptr< N > > getSons(const std::shared_ptr< N > node) const =0
virtual std::unique_ptr< NodeIterator > sonsIterator(std::shared_ptr< N > node) const =0
AssociationGraphObserver< N, E >::NodeIterator NodeIterator
virtual bool hasFather(const std::shared_ptr< N > nodeObject) const =0
Defines a Graph Associator. It is a template which follows (subscribed to) a Graph.
unsigned int NodeId
Definition: Graph.h:66
unsigned int EdgeId
Definition: Graph.h:67