bpp-core3  3.0.0
AssociationDAGraphObserver.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_ASSOCIATIONDAGRAPHOBSERVER_H
6 #define BPP_GRAPH_ASSOCIATIONDAGRAPHOBSERVER_H
7 
8 #include <iostream>
9 #include <map>
10 #include <memory>
11 #include <ostream>
12 #include <vector>
13 
15 #include "DAGraph.h"
16 
17 namespace bpp
18 {
26 template<class N, class E>
28  public virtual AssociationGraphObserver<N, E>
29 {
30 public:
33 
34  typedef typename DAGraph::NodeId NodeGraphid;
35  typedef typename DAGraph::EdgeId EdgeGraphid;
36 
37 public:
43  virtual bool isValid() const = 0;
44 
50  virtual bool isRooted() const = 0;
51 
58  virtual void rootAt(const std::shared_ptr<N> root) = 0;
59 
60 
67  virtual std::vector<std::shared_ptr<N>> getFathers(const std::shared_ptr<N> node) const = 0;
68 
69  virtual std::vector<NodeIndex> getFathers(const NodeIndex node) const = 0;
70 
75  virtual bool hasFather(const std::shared_ptr<N> nodeObject) const = 0;
76  virtual bool hasFather(const NodeIndex node) const = 0;
77 
84  virtual std::vector<std::shared_ptr<N>> getSons(const std::shared_ptr<N> node) const = 0;
85 
86  virtual std::vector<NodeIndex> getSons(const NodeIndex node) const = 0;
87 
94  virtual std::shared_ptr<N> getSon(const std::shared_ptr<E> edge) const = 0;
95  virtual NodeIndex getSon(const EdgeIndex edge) const = 0;
96 
103  virtual std::shared_ptr<N> getFatherOfEdge(const std::shared_ptr<E> edge) const = 0;
104  virtual NodeIndex getFatherOfEdge(const EdgeIndex edge) const = 0;
105 
112  virtual size_t getNumberOfSons(const std::shared_ptr<N> node) const = 0;
113 
120  virtual size_t getNumberOfFathers(const std::shared_ptr<N> node) const = 0;
121 
129  virtual std::vector<std::shared_ptr<N>> getLeavesUnderNode(std::shared_ptr<N> node) const = 0;
130 
136  virtual std::vector<std::shared_ptr<N>> removeSons(const std::shared_ptr<N> node) = 0;
137 
144  virtual void removeSon(const std::shared_ptr<N> node, const std::shared_ptr<N> son) = 0;
145 
154  virtual void addSon(const std::shared_ptr<N> nodeObject, const std::shared_ptr<N> sonNodeObject, const std::shared_ptr<E> edgeObject = 0) = 0;
155 
161  virtual std::vector<std::shared_ptr<N>> removeFathers(const std::shared_ptr<N> node) = 0;
162 
167  virtual void removeFather(const std::shared_ptr<N> node, const std::shared_ptr<N> father) = 0;
168 
177  virtual void addFather(const std::shared_ptr<N> nodeObject, const std::shared_ptr<N> fatherNodeObject, const std::shared_ptr<E> edgeObject = 0) = 0;
178 
184  /*
185  * @brief builds iterator on the neighbor nodes of a Node
186  *
187  */
188 
191 
192 
193  /*
194  * @brief builds iterator on the sons of a Node
195  *
196  */
197 
198  virtual std::unique_ptr<NodeIterator> sonsIterator(std::shared_ptr<N> node) = 0;
199 
200  virtual std::unique_ptr<NodeIterator> sonsIterator(std::shared_ptr<N> node) const = 0;
201 
202  /*
203  * @brief builds iterator on the fathers of a Node
204  *
205  */
206 
207  virtual std::unique_ptr<NodeIterator> fathersIterator(std::shared_ptr<N> node) = 0;
208 
209  virtual std::unique_ptr<NodeIterator> fathersIterator(std::shared_ptr<N> node) const = 0;
210 
219  virtual std::vector<std::shared_ptr<N>> getBelowNodes(const std::shared_ptr<N> localRoot) = 0;
220 
221  virtual std::vector<std::shared_ptr<E>> getBelowEdges(const std::shared_ptr<N> localRoot) = 0;
222 };
223 }
224 #endif // BPP_GRAPH_ASSOCIATIONDAGRAPHOBSERVER_H
virtual void addFather(const std::shared_ptr< N > nodeObject, const std::shared_ptr< N > fatherNodeObject, const std::shared_ptr< E > edgeObject=0)=0
virtual std::vector< std::shared_ptr< N > > getSons(const std::shared_ptr< N > node) const =0
virtual void rootAt(const std::shared_ptr< N > root)=0
Sets the root and make the DAG directed from root to leaves.
Defines a Graph Associator. It is a template which follows (subscribed to) a Graph.
AssociationGraphObserver< N, E >::NodeIterator NodeIterator
Defines a DA Graph Associator. It is a template which follows (subscribed to) a Graph.
virtual std::unique_ptr< NodeIterator > fathersIterator(std::shared_ptr< N > node)=0
unsigned int NodeId
Definition: Graph.h:30
virtual std::vector< std::shared_ptr< N > > getLeavesUnderNode(std::shared_ptr< N > node) const =0
virtual std::vector< std::shared_ptr< N > > removeSons(const std::shared_ptr< N > node)=0
AssociationDAGraphObserver< N, E >::EdgeIndex EdgeIndex
virtual std::vector< std::shared_ptr< E > > getBelowEdges(const std::shared_ptr< N > localRoot)=0
virtual bool hasFather(const std::shared_ptr< N > nodeObject) const =0
virtual std::shared_ptr< N > getFatherOfEdge(const std::shared_ptr< E > edge) const =0
AssociationGraphObserver< N, E >::EdgeIterator EdgeIterator
virtual std::unique_ptr< NodeIterator > sonsIterator(std::shared_ptr< N > node)=0
virtual size_t getNumberOfFathers(const std::shared_ptr< N > node) const =0
virtual std::vector< std::shared_ptr< N > > getBelowNodes(const std::shared_ptr< N > localRoot)=0
Get Below Objects.
virtual std::vector< std::shared_ptr< N > > getFathers(const std::shared_ptr< N > node) const =0
virtual void removeFather(const std::shared_ptr< N > node, const std::shared_ptr< N > father)=0
virtual bool isValid() const =0
virtual bool isRooted() const =0
virtual size_t getNumberOfSons(const 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
unsigned int EdgeId
Definition: Graph.h:31
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
virtual std::shared_ptr< N > getSon(const std::shared_ptr< E > edge) const =0