1 #ifndef DATA_FORMATS_MATH_GRAPH_H
2 #define DATA_FORMATS_MATH_GRAPH_H
12 template <
class N,
class E>
17 using edge_type = std::pair<index_type, index_type>;
48 return ((
vt_.a_ == i.
vt_.a_) && (
vt_.e_ == i.
vt_.e_)) ?
true :
false;
52 return ((
vt_.a_ == i.
vt_.a_) && (
vt_.e_ == i.
vt_.e_)) ?
false :
true;
56 while (
vt_.gr_.size() >
vt_.a_) {
64 while (
vt_.gr_.size() >
vt_.a_) {
65 if (!
vt_.gr_.adjl_[
vt_.a_].empty()) {
129 void addEdge(
const N &from,
const N &
to,
const E &edge);
153 bool replace(
const N &oldNode,
const N &newNode);
156 bool replaceEdge(
const E &ldEdge,
const E &newEdge);
165 const_iterator
begin_iter()
const {
return const_iterator(*
this); }
167 const_iterator
end_iter()
const {
return const_iterator(*
this,
adjl_.size(), 0); }
204 template <
class N,
class E>
210 nodes_.emplace_back(node);
213 idx = result.first->second;
218 template <
class N,
class E>
220 typename indexer_type::const_iterator
result = indexer_.find(node);
223 if (result != indexer_.end()) {
225 idx = result->second;
230 template <
class N,
class E>
235 adjl_[iFrom].emplace_back(
edge_type(iTo, edges_.size()));
236 edges_.emplace_back(edge);
239 template <
class N,
class E>
242 return edge_range(edges.begin(), edges.end());
245 template <
class N,
class E>
247 const edge_list &edges = adjl_[nodeIndex];
251 template <
class N,
class E>
255 if (idxResult.second) {
256 result = edges(idxResult.first);
261 template <
class N,
class E>
265 if (idxResult.second) {
266 result = edges(idxResult.first);
271 template <
class N,
class E>
273 return nodes_[edge.first];
276 template <
class N,
class E>
281 template <
class N,
class E>
283 return nodes_[it - adjl_.begin()];
286 template <
class N,
class E>
292 std::vector<bool> rootCandidate(
size(),
true);
294 for (; it != ed; ++it) {
296 for (
auto const &el_it : el) {
297 rootCandidate[el_it.first] =
false;
302 for (; v_sz < v_ed; ++v_sz) {
303 if (rootCandidate[v_sz]) {
309 template <
class N,
class E>
311 typename indexer_type::iterator it = indexer_.find(oldNode);
312 if (it != indexer_.end()) {
314 nodes_[oldIndex] = newNode;
315 indexer_[newNode] = oldIndex;
322 template <
class N,
class E>
327 for (; it < ed; ++it) {
328 if (edges_[it] == oldEdge) {
330 edges_[it] = newEdge;
337 template <
class N,
class E>
345 template <
class N,
class E>
350 for (; it < ed; ++it) {
355 for (; eit < eed; ++eit) {
357 g.
addEdge(nodeData(e.first), nodeData(it), edgeData(e.second));
362 template <
class N,
class E>
371 template <
typename T>
372 std::ostream &operator<<(std::ostream &o, const std::vector<std::vector<std::pair<T, T> > >
v) {
373 typedef typename std::vector<std::vector<std::pair<T, T> > > v_t;
374 typedef typename std::vector<std::pair<T, T> > i_t;
376 typename v_t::const_iterator it(
v.begin()), ed(
v.end());
377 for (; it != ed; ++it) {
378 typename i_t::const_iterator iit(it->begin()), ied(it->end());
379 for (; iit != ied; ++iit) {
380 o << iit->first <<
':' << iit->second << std::endl;
bool operator!=(const const_iterator &i) const
const_adj_iterator begin() const
const_iterator(const Graph &g)
std::vector< double >::size_type index_type
bool operator<(const const_iterator &i) const
edge_range edges(index_type nodeIndex)
void addEdge(const N &from, const N &to, const E &edge)
std::pair< const_edge_iterator, const_edge_iterator > const_edge_range
auto size() const -> adj_list::size_type
index_type addNode(const N &)
std::pair< index_type, bool > index_result
const_iterator end_iter() const
void invert(Graph &g) const
std::vector< AnotherDummy2 > edge_store
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
bool replace(const N &oldNode, const N &newNode)
edge_list::iterator edge_iterator
std::pair< edge_iterator, edge_iterator > edge_range
Container::value_type value_type
const_iterator begin_iter() const
adj_list::iterator adj_iterator
const N & nodeData(const edge_type &) const
const E & edgeData(index_type i) const
const_adj_iterator end() const
void findRoots(edge_list &) const
index_result nodeIndex(const N &) const
const value_type & operator*() const
void swap(Graph< N, E > &)
void clear()
it clear everything!
std::map< Node2, index_type > indexer_type
std::vector< Node2 > node_list
const value_type * operator->() const
std::pair< index_type, index_type > edge_type
Graph::index_type index_type
std::vector< edge_list > adj_list
std::vector< edge_type > edge_list
const_iterator(const Graph &g, index_type ait, index_type eit)
typename indexer_type::iterator indexer_iterator
const E & edge(void) const
value_type(const N &n, const E &e)
edge_list::const_iterator const_edge_iterator
Graph::edge_list edge_list
bool operator>(const const_iterator &i) const
adj_list::const_iterator const_adj_iterator
const N & from(void) const
tuple size
Write out results.
bool operator==(const const_iterator &i) const
typename indexer_type::const_iterator const_indexer_iterator
bool replaceEdge(const E &ldEdge, const E &newEdge)