bpp-core3  3.0.0
AssociationTreeGraphObserver.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_ASSOCIATIONTREEGRAPHOBSERVER_H
6 #define BPP_GRAPH_ASSOCIATIONTREEGRAPHOBSERVER_H
7 
8 #include <iostream>
9 #include <map>
10 #include <memory>
11 #include <ostream>
12 #include <vector>
13 
15 #include "TreeGraph.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 TreeGraph::NodeId NodeGraphid;
35  typedef typename TreeGraph::EdgeId EdgeGraphid;
36 
37 public:
43  virtual bool isValid() const = 0;
44 
51  virtual std::shared_ptr<E> getEdgeToFather(const std::shared_ptr<N> nodeObject) const = 0;
52 
53  virtual std::shared_ptr<E> getEdgeToFather(const NodeIndex nodeIndex) const = 0;
54 
60  virtual void rootAt(const std::shared_ptr<N> root) = 0;
61 
62  /*
63  * @brief check if rooted, ie directed
64  *
65  */
66 
67  virtual bool isRooted() const = 0;
68 
75  virtual std::shared_ptr<N> getFatherOfNode(const std::shared_ptr<N> nodeObject) const = 0;
76 
81  virtual bool hasFather(const std::shared_ptr<N> nodeObject) const = 0;
82  virtual bool hasFather(const NodeIndex node) const = 0;
83 
90  virtual std::vector<std::shared_ptr<N>> getSons(const std::shared_ptr<N> node) const = 0;
91 
92  virtual std::vector<NodeIndex> getSons(const NodeIndex node) const = 0;
93 
100  virtual std::vector<std::shared_ptr<E>> getBranches(const std::shared_ptr<N> node) const = 0;
101 
102  virtual std::vector<EdgeIndex> getBranches(const NodeIndex node) const = 0;
103 
110  virtual std::shared_ptr<N> getSon(const std::shared_ptr<E> edge) const = 0;
111  virtual NodeIndex getSon(const EdgeIndex edge) const = 0;
112 
119  virtual std::shared_ptr<N> getFatherOfEdge(const std::shared_ptr<E> edge) const = 0;
120  virtual NodeIndex getFatherOfEdge(const EdgeIndex edge) const = 0;
121 
128  virtual size_t getNumberOfSons(const std::shared_ptr<N> node) const = 0;
129 
137  virtual std::vector<std::shared_ptr<N>> getLeavesUnderNode(std::shared_ptr<N> node) const = 0;
138 
144  virtual std::vector<std::shared_ptr<N>> removeSons(const std::shared_ptr<N> node) = 0;
145 
150  virtual void removeSon(const std::shared_ptr<N> node, const std::shared_ptr<N> son) = 0;
151 
160  virtual void setFather(const std::shared_ptr<N> nodeObject, const std::shared_ptr<N> fatherNodeObject, const std::shared_ptr<E> edgeObject = 0) = 0;
161 
170  virtual void addSon(const std::shared_ptr<N> nodeObject, const std::shared_ptr<N> sonNodeObject, const std::shared_ptr<E> edgeObject = 0) = 0;
171 
177  /*
178  * @brief builds iterator on the neighbor nodes of a Node
179  *
180  */
181 
184 
185 
186  /*
187  * @brief builds iterator on the sons of a Node
188  *
189  */
190 
191  virtual std::unique_ptr<NodeIterator> sonsIterator(std::shared_ptr<N> node) = 0;
192 
193  virtual std::unique_ptr<NodeIterator> sonsIterator(std::shared_ptr<N> node) const = 0;
194 
195  /*
196  * @brief builds iterator on the branches to sons of a Node
197  *
198  */
199 
200  virtual std::unique_ptr<EdgeIterator> branchesIterator(std::shared_ptr<N> node) = 0;
201 
202  virtual std::unique_ptr<EdgeIterator> branchesIterator(std::shared_ptr<N> node) const = 0;
203 
214  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;
215 
216  virtual std::vector<std::shared_ptr<E>> getEdgePathBetweenTwoNodes(const std::shared_ptr<N> nodeA, const std::shared_ptr<N> nodeB) const = 0;
217 
218  virtual std::vector<std::shared_ptr<N>> getSubtreeNodes(const std::shared_ptr<N> localRoot) const = 0;
219 
220  virtual std::vector<std::shared_ptr<E>> getSubtreeEdges(const std::shared_ptr<N> localRoot) const = 0;
221 };
222 }
223 #endif // BPP_GRAPH_ASSOCIATIONTREEGRAPHOBSERVER_H
AssociationTreeGraphObserver< N, E >::EdgeIndex EdgeIndex
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 std::shared_ptr< E > getEdgeToFather(const std::shared_ptr< N > nodeObject) const =0
Defines a Graph Associator. It is a template which follows (subscribed to) a Graph.
virtual bool isValid() const =0
virtual std::vector< std::shared_ptr< E > > getSubtreeEdges(const std::shared_ptr< N > localRoot) const =0
virtual void setFather(const std::shared_ptr< N > nodeObject, const std::shared_ptr< N > fatherNodeObject, const std::shared_ptr< E > edgeObject=0)=0
AssociationTreeGraphObserver< N, E >::NodeIndex NodeIndex
virtual std::shared_ptr< N > getFatherOfEdge(const std::shared_ptr< E > edge) 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< EdgeIterator > branchesIterator(std::shared_ptr< N > node)=0
virtual std::vector< std::shared_ptr< E > > getEdgePathBetweenTwoNodes(const std::shared_ptr< N > nodeA, const std::shared_ptr< N > nodeB) const =0
Defines a Tree Graph Associator. It is a template which follows (subscribed to) a Graph...
unsigned int NodeId
Definition: Graph.h:30
virtual std::unique_ptr< NodeIterator > sonsIterator(std::shared_ptr< N > node)=0
virtual bool hasFather(const std::shared_ptr< N > nodeObject) 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 bool isRooted() const =0
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 >::NodeIterator NodeIterator
AssociationGraphObserver< N, E >::EdgeIterator EdgeIterator
virtual void removeSon(const std::shared_ptr< N > node, const std::shared_ptr< N > son)=0
virtual std::vector< std::shared_ptr< N > > removeSons(const std::shared_ptr< N > node)=0
virtual size_t getNumberOfSons(const std::shared_ptr< N > node) const =0
virtual std::vector< std::shared_ptr< E > > getBranches(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::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
unsigned int EdgeId
Definition: Graph.h:31