1 #ifndef PPL_STATE_GRAPH_H_
2 #define PPL_STATE_GRAPH_H_
9 #include <containers/graph/dynamic_graph.hpp>
12 #include <containers/sequential/graph/algorithms/connected_components.h>
13 #include <containers/graph/algorithms/graph_io.hpp>
15 #include <containers/sequential/graph/graph.h>
16 #include <containers/sequential/graph/graph_util.h>
17 #include <containers/sequential/graph/vertex_iterator_adaptor.h>
18 #include <containers/sequential/graph/algorithms/connected_components.h>
19 #include <containers/sequential/graph/algorithms/graph_input_output.h>
23 #define INVALID_VID (std::numeric_limits<size_t>::max())
27 #define INVALID_EID (std::numeric_limits<size_t>::max())
37 #include <unordered_map>
38 #include <unordered_set>
59 template <
typename Vertex,
typename Edge>
62 stapl::dynamic_graph<stapl::DIRECTED, stapl::NONMULTIEDGES, Vertex, Edge>
64 stapl::sequential::graph<stapl::DIRECTED, stapl::NONMULTIEDGES, Vertex,
76 stapl::dynamic_graph<stapl::DIRECTED,stapl::NONMULTIEDGES,Vertex, Edge>
78 stapl::sequential::graph<stapl::DIRECTED, stapl::NONMULTIEDGES, Vertex, Edge>
83 typedef typename STAPLGraph::vertex_descriptor
VID;
84 typedef typename STAPLGraph::edge_descriptor
EID;
85 typedef typename EID::edge_id_type
EdgeID;
89 typedef typename STAPLGraph::vertex_iterator
VI;
90 typedef typename STAPLGraph::adj_edge_iterator
EI;
91 typedef typename STAPLGraph::const_vertex_iterator
CVI;
92 typedef typename STAPLGraph::const_adj_edge_iterator
CEI;
95 typedef typename STAPLGraph::vertex_property
VP;
96 typedef typename STAPLGraph::edge_property
EP;
101 typedef stapl::sequential::vector_property_map<STAPLGraph, size_t>
ColorMap;
175 const std::pair<Edge, Edge>& _w) noexcept;
235 template <typename T>
265 template <typename T>
272 template <typename T>
366 template <typename RG>
367 friend
void Read(RG* _g, const std::
string& _filename);
369 template <typename RG>
382 size_t get_num_edges() {
return this->num_edges();}
383 size_t get_num_vertices()
const {
return this->num_vertices();}
384 size_t get_degree(
const VID& _vd) {
return this->find_vertex(_vd)->size();}
385 size_t get_out_degree(
const VID& _vd) {
return this->get_degree(_vd);}
396 using STAPLGraph::add_vertex;
397 using STAPLGraph::add_edge;
398 using STAPLGraph::delete_vertex;
399 using STAPLGraph::delete_edge;
466 template <
typename Vertex,
typename Edge>
470 template <
typename Vertex,
typename Edge>
476 template <
typename Vertex,
typename Edge>
483 template <
typename Vertex,
typename Edge>
486 *
this = std::move(_r);
490 template <
typename Vertex,
typename Edge>
498 STAPLGraph::operator=(_r);
507 m_ccTracker->SetRoadmap(
this);
518 template <
typename Vertex,
typename Edge>
526 STAPLGraph::operator=(std::move(_r));
527 m_robot = _r.m_robot;
528 m_timestamp = _r.m_timestamp;
529 m_predecessors = std::move(_r.m_predecessors);
530 m_allVIDs = _r.m_allVIDs;
534 m_ccTracker = std::move(_r.m_ccTracker);
535 m_ccTracker->SetRoadmap(
this);
546 template <
typename Vertex,
typename Edge>
553 if(this->Size() != _r.Size() or this->get_num_edges() != _r.get_num_edges())
557 for(
auto va = this->begin(); va != this->end(); ++va) {
559 auto vb = _r.find_vertex(va->descriptor());
562 if(va->property() != vb->property() or va->size() != vb->size())
567 for(
auto ea = va->begin(); ea != va->end(); ++ea) {
569 if(!_r.GetEdge(ea->source(), ea->target(), eb)
570 or ea->property() != eb->property())
579 template <
typename Vertex,
typename Edge>
583 return !(*
this == _r);
588 template <
typename Vertex,
typename Edge>
594 if(IsVertex(_v, vi)) {
598 return vi->descriptor();
602 const VID vid = this->add_vertex(_v);
604 m_allVIDs.insert(vid);
608 ExecuteAddVertexHooks(this->find_vertex(vid));
613 template <
typename Vertex,
typename Edge>
619 if(IsVertex(_v, vi)) {
623 return vi->descriptor();
626 if(m_allVIDs.count(_vid) > 0) {
634 const VID vid = this->add_vertex(_vid, _v);
636 m_allVIDs.insert(vid);
640 ExecuteAddVertexHooks(this->find_vertex(vid));
645 template <
typename Vertex,
typename Edge>
650 const VID vid = this->add_vertex(_v);
654 ExecuteAddVertexHooks(this->find_vertex(vid));
660 template <
typename Vertex,
typename Edge>
665 VI vi = this->find_vertex(_v);
666 if(vi == this->end())
673 for(
auto edge = vi->begin(); edge != vi->end(); edge = vi->begin())
677 auto predIter = m_predecessors.find(_v);
679 while(!preds.empty()) {
680 const VID predecessor = *preds.begin();
681 DeleteEdge(predecessor, _v);
685 ExecuteDeleteVertexHooks(vi);
688 this->delete_vertex(vi->descriptor());
689 m_predecessors.erase(predIter);
695 template <
class Vertex,
class Edge>
698 AddEdge(
const VID _source,
const VID _target,
const Edge& _w) noexcept {
701 const auto edgeDescriptor = this->add_edge(_source, _target, _w);
702 const bool notNew = edgeDescriptor.id() ==
INVALID_EID;
711 return edgeDescriptor;
715 m_predecessors[_target].insert(_source);
721 this->find_edge(edgeDescriptor, vi, ei);
722 ExecuteAddEdgeHooks(ei);
723 return edgeDescriptor;
727 template <
class Vertex,
class Edge>
733 const auto edgeDescriptor = this->add_edge(_source, _target);
734 const bool notNew = edgeDescriptor.id() ==
INVALID_EID;
742 return edgeDescriptor;
746 m_predecessors[_target].insert(_source);
752 this->find_edge(edgeDescriptor, vi, ei);
753 ExecuteAddEdgeHooks(ei);
754 return edgeDescriptor;
758 template <
class Vertex,
class Edge>
761 AddEdge(
const VID _source,
const VID _target,
const std::pair<Edge, Edge>& _w)
763 EID e1 = AddEdge(_source, _target, _w.first);
764 EID e2 = AddEdge(_target, _source, _w.second);
765 return std::make_pair(e1, e2);
769 template <
class Vertex,
class Edge>
772 AddEdge(
const EID _eid,
const Edge& _w) noexcept {
775 const auto edgeDescriptor = this->add_edge(_eid, _w);
776 const bool notNew = edgeDescriptor.id() ==
INVALID_EID;
778 auto source = _eid.source();
779 auto target = _eid.target();
787 return edgeDescriptor;
791 m_predecessors[target].insert(source);
797 this->find_edge(edgeDescriptor, vi, ei);
798 ExecuteAddEdgeHooks(ei);
799 return edgeDescriptor;
803 template <
class Vertex,
class Edge>
808 const EID edgeDescriptor(_source, _target);
812 const bool found = this->find_edge(edgeDescriptor, dummy, edgeIterator);
815 <<
") does not exist.";
817 DeleteEdge(edgeIterator);
821 template <
class Vertex,
class Edge>
826 const VID source = _iterator->source(),
827 target = _iterator->target();
828 ExecuteDeleteEdgeHooks(_iterator);
831 this->delete_edge(_iterator->descriptor());
832 m_predecessors[target].erase(source);
837 template <
typename Vertex,
typename Edge>
842 for(
VI vi = this->begin(); vi != this->end(); ++vi)
843 vi->property().SetRobot(_r);
847 template <
typename Vertex,
typename Edge>
852 std::unordered_map<VID, VID> oldToNew;
853 for(
auto vit = _r.begin(); vit != _r.end(); ++vit) {
854 const VID oldVID = vit->descriptor();
855 const VID newVID = AddVertex(vit->property());
856 oldToNew[oldVID] = newVID;
860 for(
auto vit = _r.begin(); vit != _r.end(); ++vit) {
861 for(
auto eit = vit->begin(); eit != vit->end(); ++eit) {
862 const VID source = oldToNew[eit->source()];
863 const VID target = oldToNew[eit->target()];
864 if(!IsEdge(source, target))
865 AddEdge(source, target, eit->property());
871 template <
typename Vertex,
typename Edge>
878 m_ccTracker->SetStatClass(_stats);
883 template <
typename Vertex,
typename Edge>
887 Size() const noexcept {
888 return this->get_num_vertices();
892 template <
typename Vertex,
typename Edge>
897 return this->find_vertex(_vid) != this->end();
900 template <
typename Vertex,
typename Edge>
904 IsVertex(
const Vertex& _v)
const noexcept {
906 return IsVertex(_v, vi);
910 template <
typename Vertex,
typename Edge>
914 IsVertex(
const Vertex& _v,
CVI& _vi)
const noexcept {
916 for(
CVI vi = this->begin(); vi != this->end(); ++vi){
917 if(vi->property() == _v){
923 std::cerr <<
"WARNING::STAPL working on fixing problem with const iterators\n";
929 template <
typename Vertex,
typename Edge>
933 IsEdge(
const VID _source,
const VID _target)
const noexcept {
936 return this->find_edge(
EID(_source, _target), vi, ei);
940 template <
typename Vertex,
typename Edge>
941 template <
typename T>
945 GetVID(
const T& _t)
const noexcept {
950 template <
typename Vertex,
typename Edge>
954 GetVID(
const VI& _t)
const noexcept {
955 return _t->descriptor();
959 template <
typename Vertex,
typename Edge>
963 GetVID(
const Vertex& _t)
const noexcept {
966 return vi->descriptor();
971 template <
typename Vertex,
typename Edge>
976 return m_predecessors.at(_vid);
980 template <
typename Vertex,
typename Edge>
985 if(this->get_num_vertices() == 0)
988 return (--this->end())->descriptor();
992 template <
typename Vertex,
typename Edge>
1001 template <
typename Vertex,
typename Edge>
1011 template <
typename Vertex,
typename Edge>
1020 template <
typename Vertex,
typename Edge>
1025 return m_ccTracker.get();
1029 template <
typename Vertex,
typename Edge>
1030 template <
typename T>
1035 return GetVertex(
VID(*_t));
1039 template <
typename Vertex,
typename Edge>
1044 return _t->property();
1048 template <
typename Vertex,
typename Edge>
1053 VI iter = this->find_vertex(_t);
1054 if(iter == this->end())
1056 <<
"', which is not in the graph.";
1058 return iter->property();
1062 template <
typename Vertex,
typename Edge>
1063 template <
typename T>
1068 return GetVertex(
VID(*_t));
1072 template <
typename Vertex,
typename Edge>
1077 return (*_t).property();
1081 template <
typename Vertex,
typename Edge>
1086 CVI iter = this->find_vertex(_t);
1087 if(iter == this->end())
1089 <<
"', which is not in the graph.";
1091 return (*iter).property();
1095 template <
typename Vertex,
typename Edge>
1096 std::vector<typename GenericStateGraph<Vertex, Edge>::VID>
1099 auto vi = this->find_vertex(_vid);
1100 if(vi == this->end())
1102 <<
"', which is not in the graph.";
1104 std::vector<VID> output;
1105 for(
const auto& e : *vi)
1106 output.push_back(e.target());
1111 template <
typename Vertex,
typename Edge>
1115 auto predIter = m_predecessors.find(_vid);
1117 return preds.size();
1121 template <
typename Vertex,
typename Edge>
1122 std::vector<typename GenericStateGraph<Vertex, Edge>::EI>
1125 std::vector<EI> inEdges;
1127 auto predIter = m_predecessors.find(_vid);
1128 VertexSet& predecessors = predIter->second;
1130 for(
const auto pred : predecessors) {
1131 auto predIter = this->find_vertex(pred);
1132 for(
auto eit = predIter->begin(); eit != predIter->end(); ++eit)
1133 if(eit->target() == _vid)
1134 inEdges.push_back(eit);
1141 template <
typename Vertex,
typename Edge>
1147 return this->find_edge(
EID(_source, _target), vi, _ei);
1151 template <
typename Vertex,
typename Edge>
1157 return this->find_edge(
EID(_source, _target), vi, _ei);
1161 template <
typename Vertex,
typename Edge>
1167 if(!GetEdge(_source, _target, ei))
1169 << _source <<
", " << _target <<
").";
1171 return ei->property();
1175 template <
typename Vertex,
typename Edge>
1180 return GetEdge(_descriptor.source(), _descriptor.target());
1185 template <
typename Vertex,
typename Edge>
1190 case HookType::AddVertex:
1191 return m_addVertexHooks.count(_label);
1192 case HookType::DeleteVertex:
1193 return m_deleteVertexHooks.count(_label);
1194 case HookType::AddEdge:
1195 return m_addEdgeHooks.count(_label);
1196 case HookType::DeleteEdge:
1197 return m_deleteEdgeHooks.count(_label);
1200 << ToString(_type) <<
"'.";
1205 template <
typename Vertex,
typename Edge>
1211 if(IsHook(_type, _label))
1213 <<
"' with label '" << _label
1214 <<
"' already exists.";
1217 case HookType::AddVertex:
1218 m_addVertexHooks[_label] = _h;
1220 case HookType::DeleteVertex:
1221 m_deleteVertexHooks[_label] = _h;
1223 case HookType::AddEdge:
1224 case HookType::DeleteEdge:
1226 <<
"' used with vertex hook function "
1227 <<
"labeled '" << _label <<
"'.";
1231 <<
"' with label '" << _label <<
"'.";
1236 template <
typename Vertex,
typename Edge>
1241 if(IsHook(_type, _label))
1243 <<
"' with label '" << _label
1244 <<
"' already exists.";
1247 case HookType::AddEdge:
1248 m_addEdgeHooks[_label] = _h;
1250 case HookType::DeleteEdge:
1251 m_deleteEdgeHooks[_label] = _h;
1253 case HookType::AddVertex:
1254 case HookType::DeleteVertex:
1256 <<
"' used with edge hook function labeled '"
1261 <<
"' with label '" << _label <<
"'.";
1266 template <
typename Vertex,
typename Edge>
1270 if(!IsHook(_type, _label))
1272 <<
"' with label '" << _label
1273 <<
"' does not exist.";
1276 case HookType::AddVertex:
1277 m_addVertexHooks.erase(_label);
1279 case HookType::DeleteVertex:
1280 m_deleteVertexHooks.erase(_label);
1282 case HookType::AddEdge:
1283 m_addEdgeHooks.erase(_label);
1285 case HookType::DeleteEdge:
1286 m_deleteEdgeHooks.erase(_label);
1291 <<
"' with label '" << _label <<
"'.";
1296 template <
typename Vertex,
typename Edge>
1301 m_enableHooks =
false;
1305 template <
typename Vertex,
typename Edge>
1310 m_enableHooks =
true;
1314 template <
typename Vertex,
typename Edge>
1318 m_addVertexHooks.clear();
1319 m_deleteVertexHooks.clear();
1320 m_addEdgeHooks.clear();
1321 m_deleteEdgeHooks.clear();
1335 template <
typename GenericStateGraph>
1338 std::ifstream ifs(_filename);
1343 bool headerParsed =
false;
1346 while(!headerParsed) {
1348 graphStart = ifs.tellg();
1351 <<
"' - GRAPHSTART tag is missing.";
1354 if(tag.find(
"GRAPHSTART") != std::string::npos)
1355 headerParsed =
true;
1362 typedef typename GenericStateGraph::vertex_property Vertex;
1363 typedef typename GenericStateGraph::edge_property Edge;
1369 Vertex::inputRobot = _g->
GetRobot();
1372 ifs.seekg(graphStart, ifs.beg);
1373 stapl::sequential::read_graph<STAPLGraph>(*_g, ifs);
1376 Edge::inputRobot =
nullptr;
1377 Vertex::inputRobot =
nullptr;
1379 for(
auto vi = _g->begin(); vi != _g->end(); ++vi)
1381 for(
auto vi = _g->begin(); vi != _g->end(); ++vi)
1382 for(
auto ei = vi->begin(); ei != vi->end(); ++ei)
1386 template <
typename Vertex,
typename Edge>
1389 Read(
const std::string& _filename) {
1390 std::ifstream ifs(_filename);
1395 bool headerParsed =
false;
1398 while(!headerParsed) {
1400 graphStart = ifs.tellg();
1403 <<
"' - GRAPHSTART tag is missing.";
1406 if(tag.find(
"GRAPHSTART") != std::string::npos)
1407 headerParsed =
true;
1416 Edge::inputRobot = GetRobot();
1417 Vertex::inputRobot = GetRobot();
1420 ifs.seekg(graphStart, ifs.beg);
1421 stapl::sequential::read_graph<STAPLGraph>(*
this, ifs);
1424 Edge::inputRobot =
nullptr;
1425 Vertex::inputRobot =
nullptr;
1436 template <
typename GenericStateGraph>
1439 std::stringstream ss(_msg);
1442 bool headerParsed =
false;
1445 while(!headerParsed) {
1447 graphStart = ss.tellg();
1450 <<
"' - GRAPHSTART tag is missing.";
1453 if(tag.find(
"GRAPHSTART") != std::string::npos)
1454 headerParsed =
true;
1461 typedef typename GenericStateGraph::vertex_property Vertex;
1462 typedef typename GenericStateGraph::edge_property Edge;
1468 Vertex::inputRobot = _g->
GetRobot();
1471 ss.seekg(graphStart, ss.beg);
1472 stapl::sequential::read_graph<STAPLGraph>(*_g, ss);
1475 Edge::inputRobot =
nullptr;
1476 Vertex::inputRobot =
nullptr;
1478 for(
auto vi = _g->begin(); vi != _g->end(); ++vi)
1480 for(
auto vi = _g->begin(); vi != _g->end(); ++vi)
1481 for(
auto ei = vi->begin(); ei != vi->end(); ++ei)
1485 template <
typename Vertex,
typename Edge>
1489 std::ofstream ofs(_filename);
1490 ofs <<
"#####ENVFILESTART#####" << std::endl
1492 <<
"#####ENVFILESTOP#####" << std::endl;
1495 stapl::sequential::write_graph(*
this, ofs);
1498 stapl::graph_view<STAPLGraph> gv(*
this);
1499 write_PMPL_graph(gv, _filename);
1506 template <
typename Vertex,
typename Edge>
1515 m_ccTracker->AddVertex(_iterator);
1517 for(
auto& hook : m_addVertexHooks)
1518 hook.second(_iterator);
1522 template <
typename Vertex,
typename Edge>
1530 for(
auto& hook : m_deleteVertexHooks)
1531 hook.second(_iterator);
1534 m_ccTracker->DeleteVertex(_iterator);
1538 template <
typename Vertex,
typename Edge>
1547 m_ccTracker->AddEdge(_iterator);
1549 for(
auto& hook : m_addEdgeHooks)
1550 hook.second(_iterator);
1554 template <
typename Vertex,
typename Edge>
1562 for(
auto& hook : m_deleteEdgeHooks)
1563 hook.second(_iterator);
1566 m_ccTracker->DeleteEdge(_iterator);
1570 template <
typename Vertex,
typename Edge>
1575 case HookType::AddVertex:
1577 case HookType::DeleteVertex:
1578 return "DeleteVertex";
1579 case HookType::AddEdge:
1581 case HookType::DeleteEdge:
1582 return "DeleteEdge";
1584 return std::string(1,
char(_t));
1595 std::unordered_set<size_t>
1597 const std::unordered_set<size_t>& _b) {
1598 using VertexSet = std::unordered_set<size_t>;
1601 const VertexSet* smaller{
nullptr},
1603 if(_a.size() < _b.size()) {
1613 VertexSet intersection;
1614 std::copy_if(smaller->begin(), smaller->end(),
1615 std::inserter(intersection, intersection.end()),
1616 [larger](
const size_t _vid) {return larger->count(_vid);});
1617 return intersection;
1628 const std::unordered_set<size_t>& _b) {
1629 using VertexSet = std::unordered_set<size_t>;
1632 const VertexSet* smaller,
1634 if(_a.size() < _b.size()) {
1644 return std::any_of(smaller->begin(), smaller->end(),
1645 [larger](
const size_t _vid) {return larger->count(_vid);});
1653 std::unordered_set<size_t>&
1655 const std::unordered_set<size_t>& _source) {
1658 _receiver.reserve(_receiver.size() + _source.size());
1659 for(
const size_t vid : _source)
1660 _receiver.insert(vid);
1672 template <
typename T,
typename... Rest>
1681 size_t bucketIndex, bucketSize, tries = 0;
1684 bucketIndex =
DRand() * _set.bucket_count();
1685 bucketSize = _set.bucket_size(bucketIndex);
1687 while(bucketSize == 0);
1689 const size_t elementIndex =
DRand() * bucketSize;
1691 std::cout <<
"\nset size = " << _set.size()
1692 <<
"\ntries = " << tries
1693 <<
"\nbucketIndex = " << bucketIndex
1694 <<
"\nbucketSize = " << bucketSize
1695 <<
"\nelementIndex = " << elementIndex
1697 << *std::next(_set.begin(bucketIndex), elementIndex)
1700 return *std::next(_set.begin(bucketIndex), elementIndex);
1704 return *std::next(_set.begin(),
DRand() * _set.size());
void ReadMessage(GenericStateGraph *_g, const std::string &_msg)
Definition: GenericStateGraph.h:1438
void Read(GenericStateGraph *_g, const std::string &_filename)
Definition: GenericStateGraph.h:1337
#define INVALID_VID
Definition: GenericStateGraph.h:23
#define INVALID_EID
Definition: GenericStateGraph.h:27
const T & RandomElement(const std::unordered_set< T, Rest... > &_set) noexcept
Definition: GenericStateGraph.h:1675
std::unordered_set< size_t > VertexSetIntersection(const std::unordered_set< size_t > &_a, const std::unordered_set< size_t > &_b)
Definition: GenericStateGraph.h:1596
bool HaveCommonVertex(const std::unordered_set< size_t > &_a, const std::unordered_set< size_t > &_b)
Definition: GenericStateGraph.h:1627
std::unordered_set< size_t > & VertexSetUnionInPlace(std::unordered_set< size_t > &_receiver, const std::unordered_set< size_t > &_source)
Definition: GenericStateGraph.h:1654
void VDAddNode(const CfgType &_cfg)
@TODO
Definition: IOUtils.h:48
double DRand()
Definition: MPUtils.cpp:8
#define WHERE
Macro for retrieving info about file, function, and line number.
Definition: RuntimeUtils.h:32
Definition: CCTracker.h:36
Definition: Environment.h:137
const std::string & GetEnvFileName() const noexcept
Get the environment file name.
Definition: Environment.cpp:332
Definition: GenericStateGraph.h:67
virtual EID AddEdge(const VID _source, const VID _target, const Edge &_w) noexcept
Definition: GenericStateGraph.h:698
friend void ReadMessage(RG *_g, const std::string &_msg)
STAPLGraph::edge_property EP
Definition: GenericStateGraph.h:96
void InstallHook(const HookType _type, const std::string &_label, const VertexHook &_h)
Definition: GenericStateGraph.h:1208
virtual void DeleteVertex(const VID _v) noexcept
Definition: GenericStateGraph.h:663
std::unordered_map< std::string, VertexHook > m_addVertexHooks
Hook functions to call when adding a vertex.
Definition: GenericStateGraph.h:437
std::unique_ptr< CCTrackerType > m_ccTracker
Tracks weak CCs within the roadmap.
Definition: GenericStateGraph.h:447
std::function< void(VI)> VertexHook
Definition: GenericStateGraph.h:104
Edge EdgeType
Definition: GenericStateGraph.h:99
bool operator==(const GenericStateGraph &_r) const noexcept
Definition: GenericStateGraph.h:549
virtual void Write(const std::string &_filename, Environment *_env) const
Definition: GenericStateGraph.h:1488
STAPLGraph::vertex_descriptor VID
Definition: GenericStateGraph.h:83
Robot * GetRobot() const noexcept
Get the robot represented by this roadmap.
Definition: GenericStateGraph.h:1015
void SetCCTracker(StatClass *const _stats=nullptr)
Definition: GenericStateGraph.h:875
VertexSet m_allVIDs
Definition: GenericStateGraph.h:458
void ExecuteAddVertexHooks(const VI _iterator) noexcept
Definition: GenericStateGraph.h:1510
const VertexSet & GetPredecessors(const VID _vid) const noexcept
Definition: GenericStateGraph.h:975
virtual void ClearHooks() noexcept
Definition: GenericStateGraph.h:1317
size_t GetInDegree(const VID _vid) noexcept
Definition: GenericStateGraph.h:1114
Vertex CfgType
Definition: GenericStateGraph.h:98
STAPLGraph::const_vertex_iterator CVI
Definition: GenericStateGraph.h:91
GenericStateGraph & operator=(GenericStateGraph &&_r)
Definition: GenericStateGraph.h:521
stapl::sequential::vector_property_map< STAPLGraph, size_t > ColorMap
Definition: GenericStateGraph.h:101
virtual VID AddVertex(const VID _vid, const Vertex &_v) noexcept
Definition: GenericStateGraph.h:616
void ExecuteDeleteEdgeHooks(const EI _iterator) noexcept
Definition: GenericStateGraph.h:1558
GenericStateGraph & operator=(const GenericStateGraph &_r)
Definition: GenericStateGraph.h:493
const VertexSet & GetAllVIDs() const noexcept
Get the set of all VIDs in the roadmap.
Definition: GenericStateGraph.h:1005
STAPLGraph::const_adj_edge_iterator CEI
Definition: GenericStateGraph.h:92
virtual VID AddVertex(const Vertex &_v) noexcept
Definition: GenericStateGraph.h:591
void ExecuteAddEdgeHooks(const EI _iterator) noexcept
Definition: GenericStateGraph.h:1542
STAPLGraph::vertex_iterator VI
Definition: GenericStateGraph.h:89
void SetRobot(Robot *const _r) noexcept
Set the robot pointer on all configurations in the map.
Definition: GenericStateGraph.h:840
bool IsEdge(const VID _source, const VID _target) const noexcept
Definition: GenericStateGraph.h:933
size_t m_timestamp
Tracks the number of changes to the graph.
Definition: GenericStateGraph.h:432
std::vector< VID > GetChildren(const VID _vid) const noexcept
Definition: GenericStateGraph.h:1098
friend void Read(RG *_g, const std::string &_filename)
GenericStateGraph(GenericStateGraph &&_r)
Definition: GenericStateGraph.h:485
Robot * m_robot
The robot this roadmap is for.
Definition: GenericStateGraph.h:430
STAPLGraph::edge_descriptor EID
Definition: GenericStateGraph.h:84
bool operator!=(const GenericStateGraph &_r) const noexcept
Definition: GenericStateGraph.h:582
GenericStateGraph(Robot *const _r)
Definition: GenericStateGraph.h:472
size_t Size() const noexcept
Get the number of vertices in the roadmap.
Definition: GenericStateGraph.h:887
HookType
Definition: GenericStateGraph.h:106
std::function< void(EI)> EdgeHook
Definition: GenericStateGraph.h:105
STAPLGraph::adj_edge_iterator EI
Definition: GenericStateGraph.h:90
bool IsHook(const HookType, const std::string &_label) const
Definition: GenericStateGraph.h:1188
void DisableHooks() noexcept
Definition: GenericStateGraph.h:1300
std::unordered_map< std::string, VertexHook > m_deleteVertexHooks
Hook functions to call when deleting a vertex.
Definition: GenericStateGraph.h:439
void RemoveHook(const HookType _type, const std::string &_label)
Definition: GenericStateGraph.h:1269
CCTrackerType * GetCCTracker() const noexcept
Get the connected component tracker.
Definition: GenericStateGraph.h:1024
bool m_enableHooks
Use hook functions?
Definition: GenericStateGraph.h:434
void EnableHooks() noexcept
Enable the hook functions (default).
Definition: GenericStateGraph.h:1309
std::unordered_map< std::string, EdgeHook > m_addEdgeHooks
Hook functions to call when adding an edge.
Definition: GenericStateGraph.h:442
std::vector< EI > FindInboundEdges(const VID _vid)
Definition: GenericStateGraph.h:1124
std::string ToString(const HookType &_t) const noexcept
Definition: GenericStateGraph.h:1573
STAPLGraph::vertex_property VP
Definition: GenericStateGraph.h:95
std::unordered_map< VID, VertexSet > m_predecessors
Definition: GenericStateGraph.h:454
stapl::sequential::graph< stapl::DIRECTED, stapl::NONMULTIEDGES, Vertex, Edge > STAPLGraph
Definition: GenericStateGraph.h:80
bool IsVertex(const VID _vid) const noexcept
Definition: GenericStateGraph.h:896
bool GetEdge(const VID _source, const VID _target, EI &_ei) noexcept
Definition: GenericStateGraph.h:1145
VP & GetVertex(T &_t) noexcept
Retrieve a reference to a vertex property by descriptor or iterator.
Definition: GenericStateGraph.h:1034
GenericStateGraph()
Definition: GenericStateGraph.h:468
virtual void DeleteEdge(const VID _source, const VID _target) noexcept
Definition: GenericStateGraph.h:806
std::unordered_set< VID > VertexSet
Definition: GenericStateGraph.h:86
EID::edge_id_type EdgeID
Definition: GenericStateGraph.h:85
std::unordered_map< std::string, EdgeHook > m_deleteEdgeHooks
Hook functions to call when deleting an edge.
Definition: GenericStateGraph.h:444
void AppendRoadmap(const GenericStateGraph &_r)
Definition: GenericStateGraph.h:850
size_t GetTimestamp() const noexcept
Each time the roadmap is modified, we update the timestamp.
Definition: GenericStateGraph.h:996
virtual VID AddDuplicateVertex(const Vertex &_v) noexcept
Definition: GenericStateGraph.h:648
virtual void DeleteEdge(EI _iterator) noexcept
Definition: GenericStateGraph.h:824
VID GetVID(const T &_t) const noexcept
Definition: GenericStateGraph.h:945
void ExecuteDeleteVertexHooks(const VI _iterator) noexcept
Definition: GenericStateGraph.h:1526
CCTracker< GenericStateGraph< Vertex, Edge > > CCTrackerType
Definition: GenericStateGraph.h:109
GenericStateGraph(const GenericStateGraph &_r)
Definition: GenericStateGraph.h:478
VID GetLastVID() const noexcept
Get the descriptor of the last vertex added to the graph.
Definition: GenericStateGraph.h:984
Definition: MetricUtils.h:29
Definition: PMPLExceptions.h:38
Definition: PMPLExceptions.h:62