libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
SimpleGraph.h
1 #ifndef SIMPLEGRAPH_H
2 #define SIMPLEGRAPH_H
3 #define _DEBUG_SIMPLEGRAPH_H
4 #include <map>
5 #include <vector>
6 #include <deque>
7 
8 #ifdef _DEBUG_SIMPLEGRAPH_H
9 #include <iostream>
10 #endif
11 
12 #include "GraphInterface.h"
13 #include "GraphCommon.h"
14 #include "Node.h"
15 #include "Edge.h"
16 
17 namespace mho {
18 
20 {
21 public:
22  SimpleGraph(bool directed=false);
23  virtual ~SimpleGraph();
24  SimpleGraph *clone(void);
25 
26  bool isDirected();
27 
35 
36  virtual void connectNodes(NodeInterface* n1, NodeInterface* n2, cost_t c);
45  void updateCost(NodeInterface* n1,NodeInterface* n2,cost_t newcost,cost_t oldcost, bool onlySpecifiedCost=true);
46  void updateCost(NodeInterface* n1,NodeInterface* n2,cost_t newcost);
47  void updateCost(EdgeInterface *edge,cost_t cost);
48 
49 
50  NodeInterface* at(unsigned int i);
51  EdgeInterface* edgeAt(unsigned int i);
52  std::vector<NodeInterface*> sonsNodes(NodeInterface *i);
53  std::vector<EdgeInterface*> sons(NodeInterface* i);
54  std::vector<NodeInterface*> getNodes(void);
55 
56 
57  unsigned int size(void);
58  unsigned int edgesNumber(void);
59 
60  void clear(void);
61 
62 #ifdef _DEBUG_SIMPLEGRAPH_H
63  friend std::ostream& operator<<(std::ostream& os, SimpleGraph& g);
64 #endif
65 
66 protected:
67 
68  std::vector<Edge*> _edges;
69  std::vector<Node*> _nodes;
70  bool _is_directed;
71  unsigned int _count;
72 };
73 }
74 #endif // SIMPLEGRAPH_H
Definition: SimpleGraph.h:19
bool isDirected()
isDirected
Definition: SimpleGraph.cpp:34
virtual void connectNodes(NodeInterface *n1, NodeInterface *n2, cost_t c)
connectNodes connect 2 nodes.
Definition: SimpleGraph.cpp:50
NodeInterface * addNode(NodeInterface *n)
addNode
Definition: SimpleGraph.cpp:36
NodeInterface * at(unsigned int i)
at returns the node at given index
Definition: SimpleGraph.cpp:122
Definition: NodeInterface.h:11
Definition: EdgeInterface.h:12
unsigned int size(void)
size the number of nodes
Definition: SimpleGraph.cpp:143
template interface for a graph
Definition: GraphInterface.h:13
void updateCost(NodeInterface *n1, NodeInterface *n2, cost_t newcost, cost_t oldcost, bool onlySpecifiedCost=true)
update the cost of an edge specified by its pre and post node, eventually its cost ...
Definition: SimpleGraph.cpp:73
Definition: Node.h:14