-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print the number of nodes and edges.
* include/qdft/manager.hh, * include/qdft/manager.hxx: Provide get_graph_size method. * include/qdft/qdft.hh, * include/qdft/qdft.hxx: Provide get_graphs_size method. * src/test_lib.cc: Print total number of nodes and edges in addition to memory footprint.
- Loading branch information
Showing
5 changed files
with
49 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 2011, 2012 Johan Oudinet <[email protected]> | ||
// Copyright (C) 2011, 2012, 2013, 2014 Johan Oudinet <[email protected]> | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
|
@@ -44,6 +44,8 @@ namespace qdft { | |
typedef typename Traits::edge_descriptor edge_descriptor; | ||
typedef typename Traits::in_edge_iterator in_edge_iterator; | ||
typedef typename Traits::out_edge_iterator out_edge_iterator; | ||
typedef typename Traits::vertices_size_type vertices_size_type; | ||
typedef typename Traits::edges_size_type edges_size_type; | ||
typedef boost::unordered_map<cname_type, vertex_descriptor> c2v_type; | ||
|
||
/** | ||
|
@@ -98,17 +100,6 @@ namespace qdft { | |
void | ||
truncate (const cname_type& c, const quantity_type& n); | ||
|
||
// /** | ||
// * Remove q amount of data from c | ||
// * q might be greater than the amount of data | ||
// * if c does not exist just do nothing | ||
// * | ||
// * @param q amount of data to remove | ||
// * @param c container's name | ||
// */ | ||
// void | ||
// remove (const quantity_type& q, const cname_type& c); | ||
|
||
/** | ||
* Set the transfered edge value to a specific quantity. This is | ||
* usefull to revert a previous transfer. | ||
|
@@ -153,6 +144,11 @@ namespace qdft { | |
*/ | ||
void show_graph (std::ostream& out = std::cout) const; | ||
|
||
/** | ||
* Get the number of nodes and edges in the graph | ||
*/ | ||
std::pair<vertices_size_type, edges_size_type> get_graph_size () const; | ||
|
||
private: | ||
mutable Graph g_; | ||
c2v_type c2v_; // Mapping from container's name to vertex descriptor | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 2011, 2012 Johan Oudinet <[email protected]> | ||
// Copyright (C) 2011, 2012, 2014 Johan Oudinet <[email protected]> | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
|
@@ -43,6 +43,9 @@ namespace qdft { | |
public: | ||
typedef boost::unordered_map< | ||
dname_type, data_manager_ptr> data_managers_t; | ||
typedef boost::graph_traits<Graph> Traits; | ||
typedef typename Traits::vertices_size_type vertices_size_type; | ||
typedef typename Traits::edges_size_type edges_size_type; | ||
|
||
/** | ||
* Create a new data of size q (and set mode m for further updates) | ||
|
@@ -105,18 +108,6 @@ namespace qdft { | |
void | ||
truncate (const dname_type& d, const cname_type& c, const quantity_type& n); | ||
|
||
// /** | ||
// * Remove q amount of data d from c | ||
// * q might be greater than the amount of data | ||
// * if c does not exist just do nothing | ||
// * | ||
// * @param d the data name | ||
// * @param q amount of data to remove | ||
// * @param c container's name | ||
// */ | ||
// void | ||
// remove (const dname_type& d, const quantity_type& q, const cname_type& c); | ||
|
||
/** | ||
* Set the transfered edge value to a specific quantity. This is | ||
* usefull to revert a previous transfer. | ||
|
@@ -175,6 +166,11 @@ namespace qdft { | |
*/ | ||
void save (const std::string& fname) const; | ||
|
||
/** | ||
* Get the total number of nodes and edges for all graphs | ||
*/ | ||
std::pair<vertices_size_type, edges_size_type> get_graphs_size () const; | ||
|
||
private: | ||
data_managers_t dm_; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 2011, 2012 Johan Oudinet <[email protected]> | ||
// Copyright (C) 2011, 2012, 2014 Johan Oudinet <[email protected]> | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
|
@@ -208,6 +208,22 @@ namespace qdft { | |
fs.close (); | ||
} | ||
|
||
template <class Graph> | ||
std::pair<typename data_managers<Graph>::vertices_size_type, | ||
typename data_managers<Graph>::edges_size_type> | ||
data_managers<Graph>::get_graphs_size () const | ||
{ | ||
vertices_size_type n = 0; | ||
edges_size_type m = 0; | ||
BOOST_FOREACH(typename data_managers_t::value_type i, dm_) { | ||
std::pair<vertices_size_type, edges_size_type> p = | ||
i.second->get_graph_size (); | ||
n += p.first; | ||
m += p.second; | ||
} | ||
return std::make_pair (n, m); | ||
} | ||
|
||
} // end namespace qdft | ||
|
||
#endif // ! QDFT_QDFT_HXX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters