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>;
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);
218 template <
class N,
class E>
220 typename indexer_type::const_iterator
result = indexer_.find(node);
223 if (
result != indexer_.end()) {
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>
245 template <
class N,
class E>
251 template <
class N,
class E>
255 if (idxResult.second) {
261 template <
class N,
class E>
265 if (idxResult.second) {
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>
365 nodes_.swap(
g.nodes_);
366 edges_.swap(
g.edges_);
367 indexer_.swap(
g.indexer_);
368 emptyEdges_.swap(
g.emptyEdges_);
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;
void invert(Graph &g) 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)
const_iterator end_iter() const
std::pair< const_edge_iterator, const_edge_iterator > const_edge_range
const E & edge(void) const
auto size() const -> adj_list::size_type
const value_type & operator*() const
index_type addNode(const N &)
std::pair< index_type, bool > index_result
const N & from(void) const
const_adj_iterator begin() const
const N & nodeData(const edge_type &) const
bool operator==(const const_iterator &i) const
std::vector< AnotherDummy2 > edge_store
const value_type * operator->() const
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
const_adj_iterator end() const
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
adj_list::iterator adj_iterator
index_result nodeIndex(const N &) const
void swap(Graph< N, E > &)
void clear()
it clear everything!
void findRoots(edge_list &) const
std::map< Node2, index_type > indexer_type
bool operator!=(const const_iterator &i) const
std::vector< Node2 > node_list
std::pair< index_type, index_type > edge_type
Graph::index_type index_type
bool operator>(const const_iterator &i) const
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_iterator begin_iter() const
value_type(const N &n, const E &e)
edge_list::const_iterator const_edge_iterator
Graph::edge_list edge_list
adj_list::const_iterator const_adj_iterator
const E & edgeData(index_type i) const
typename indexer_type::const_iterator const_indexer_iterator
bool replaceEdge(const E &ldEdge, const E &newEdge)