bpp-core3  3.0.0
DAGraph.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_DAGRAPH_H
6 #define BPP_GRAPH_DAGRAPH_H
7 
8 #include <algorithm>
9 #include <iostream>
10 #include <ostream>
11 #include <string>
12 #include <vector>
13 
14 #include "../Exceptions.h"
15 #include "../Numeric/VectorTools.h"
16 #include "Graph.h"
17 
18 namespace bpp
19 {
20 class DAGraph :
21  public virtual Graph
22 {
23 public:
28  virtual bool isValid() const = 0;
29 
36  virtual bool isRooted() const = 0;
37 
42  virtual bool hasFather(Graph::NodeId node) const = 0;
43 
48  virtual std::vector<Graph::NodeId> getFathers(Graph::NodeId node) const = 0;
49 
54  virtual size_t getNumberOfFathers(Graph::NodeId node) const = 0;
55 
60  virtual void addFather(Graph::NodeId node, Graph::NodeId father) = 0;
61 
62  virtual void addFather(Graph::NodeId node, Graph::NodeId father, Graph::EdgeId edgeId) = 0;
63 
68  virtual void removeFather(Graph::NodeId node, Graph::NodeId father) = 0;
69 
74  virtual std::vector<Graph::NodeId> removeFathers(Graph::NodeId node) = 0;
75 
82  virtual std::vector<Graph::NodeId> getLeavesUnderNode(Graph::NodeId node) const = 0;
83 
88  virtual std::vector<Graph::NodeId> getSons(Graph::NodeId node) const = 0;
89 
94  virtual size_t getNumberOfSons(Graph::NodeId node) const = 0;
95 
100  void addSon(Graph::NodeId node, Graph::NodeId sonNode);
101 
102  void addSon(Graph::NodeId node, Graph::NodeId sonNode, Graph::EdgeId edge);
103 
108  virtual std::vector<Graph::NodeId> removeSons(Graph::NodeId node) = 0;
109 
114  virtual void removeSon(Graph::NodeId node, Graph::NodeId son) = 0;
115 
120  virtual void rootAt(Graph::NodeId newRoot) = 0;
121 
126  virtual std::vector<Graph::NodeId> getBelowNodes(Graph::NodeId localRoot) const = 0;
127 
132  virtual std::vector<Graph::EdgeId> getBelowEdges(Graph::NodeId localRoot) const = 0;
133 };
134 }
135 #endif // BPP_GRAPH_DAGRAPH_H
virtual void addFather(Graph::NodeId node, Graph::NodeId father)=0
virtual bool hasFather(Graph::NodeId node) const =0
virtual std::vector< Graph::EdgeId > getBelowEdges(Graph::NodeId localRoot) const =0
virtual bool isRooted() const =0
virtual std::vector< Graph::NodeId > removeFathers(Graph::NodeId node)=0
unsigned int NodeId
Definition: Graph.h:30
virtual void removeFather(Graph::NodeId node, Graph::NodeId father)=0
virtual bool isValid() const =0
virtual std::vector< Graph::NodeId > removeSons(Graph::NodeId node)=0
virtual std::vector< Graph::NodeId > getFathers(Graph::NodeId node) const =0
virtual std::vector< Graph::NodeId > getSons(Graph::NodeId node) const =0
virtual void rootAt(Graph::NodeId newRoot)=0
virtual std::vector< Graph::NodeId > getLeavesUnderNode(Graph::NodeId node) const =0
virtual size_t getNumberOfFathers(Graph::NodeId node) const =0
Get the number of fathers nodes.
void addSon(Graph::NodeId node, Graph::NodeId sonNode)
virtual std::vector< Graph::NodeId > getBelowNodes(Graph::NodeId localRoot) const =0
unsigned int EdgeId
Definition: Graph.h:31
virtual void removeSon(Graph::NodeId node, Graph::NodeId son)=0
virtual size_t getNumberOfSons(Graph::NodeId node) const =0
Get the number of sons node.