- Timestamp:
- 04/14/11 15:30:13 (2 years ago)
- Branches:
- master, python3
- Children:
- 5cbf85
- Parents:
- b311b0
- git-author:
- Tiago de Paula Peixoto <tiago@…> (04/14/11 14:56:39)
- git-committer:
- Tiago de Paula Peixoto <tiago@…> (04/14/11 15:30:13)
- Location:
- src/graph
- Files:
-
- 3 edited
-
histogram.hh (modified) (2 diffs)
-
stats/graph_histograms.cc (modified) (1 diff)
-
stats/graph_histograms.hh (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/graph/histogram.hh
r011d7b rec544e 59 59 for (size_t j = 0; j < Dim; ++j) 60 60 { 61 if (_bins[j].size() < 2)62 throw std::range_error("invalid bin edge number < 2!");61 if (_bins[j].size() < 1) 62 throw std::range_error("invalid bin edge number < 1!"); 63 63 64 64 _data_range[j] = std::make_pair(0, 0); 65 66 // detect whether the given bins are of constant width, for faster67 // binning68 _const_width[j] = true;69 65 value_type delta = _bins[j][1] - _bins[j][0]; 70 for (size_t i = 2; i < _bins[j].size(); ++i) 71 { 72 value_type d = _bins[j][i] - _bins[j][i-1]; 73 if (delta != d) 74 _const_width[j] = false; 75 } 76 77 if (_const_width[j]) 78 { 79 if (_bins[j].size() > 2) 80 { 66 67 if (_bins[j].size() == 2) 68 { 69 _data_range[j] = std::make_pair(_bins[j][0], _bins[j][0]); 70 delta = _bins[j][1]; 71 _const_width[j] = true; 72 } 73 else 74 { 75 // detect whether the given bins are of constant width, for faster 76 // binning 77 _const_width[j] = true; 78 for (size_t i = 2; i < _bins[j].size(); ++i) 79 { 80 value_type d = _bins[j][i] - _bins[j][i-1]; 81 if (delta != d) 82 _const_width[j] = false; 83 } 84 85 if (_const_width[j]) 81 86 _data_range[j] = std::make_pair(_bins[j].front(), 82 87 _bins[j].back()); 83 new_shape[j] = _bins[j].size() - 1; 84 } 85 else 86 { 87 _data_range[j] = std::make_pair(_bins[j].front(), 88 _bins[j].front()); 89 new_shape[j] = 1; 90 } 91 if (delta == 0) 92 throw std::range_error("invalid bin size of zero!"); 93 } 94 else 95 { 96 new_shape[j] = _bins[j].size() - 1; 97 } 88 } 89 if (delta == 0) 90 throw std::range_error("invalid bin size of zero!"); 91 92 new_shape[j] = _bins[j].size() - 1; 98 93 } 99 94 _counts.resize(new_shape); … … 107 102 if (_const_width[i]) 108 103 { 109 if (_data_range[i].first != _data_range[i].second && 110 (v[i] < _data_range[i].first || 111 v[i] > _data_range[i].second)) 112 return; // out of bounds 113 value_type delta = _bins[i][1] - _bins[i][0]; 104 value_type delta; 105 106 if (_data_range[i].first == _data_range[i].second) 107 { 108 delta = _bins[i][1]; 109 110 if (v[i] < _data_range[i].first) 111 return; // out of bounds 112 } 113 else 114 { 115 delta = _bins[i][1] - _bins[i][0]; 116 117 if (v[i] < _data_range[i].first || 118 v[i] >= _data_range[i].second) 119 return; // out of bounds 120 } 121 114 122 bin[i] = (v[i] - _data_range[i].first) / delta; 115 123 if (bin[i] >= _counts.shape()[i]) // modify shape -
src/graph/stats/graph_histograms.cc
r6758e8 rec544e 36 36 run_action<>()(gi, get_histogram<VertexHistogramFiller>(hist, bins, 37 37 ret_bins), 38 scalar_selectors())(degree_selector(deg));38 scalar_selectors())(degree_selector(deg)); 39 39 return python::make_tuple(hist, ret_bins); 40 40 } -
src/graph/stats/graph_histograms.hh
r6758e8 rec544e 36 36 public: 37 37 template <class Graph, class DegreeSelector, class Hist> 38 void operator()(Graph& g, typename graph_traits<Graph>::vertex_descriptor v, 38 void operator()(const Graph& g, 39 typename graph_traits<Graph>::vertex_descriptor v, 39 40 DegreeSelector& deg, Hist& hist) 40 41 { … … 49 50 public: 50 51 template <class Graph, class EdgeProperty, class Hist> 51 void operator()(Graph& g, typename graph_traits<Graph>::vertex_descriptor v, 52 void operator()(const Graph& g, 53 typename graph_traits<Graph>::vertex_descriptor v, 52 54 EdgeProperty& eprop, Hist& hist) 53 55 { … … 72 74 73 75 template <class Graph, class DegreeSelector> 74 void operator()( Graph& g, DegreeSelector deg) const76 void operator()(const Graph& g, DegreeSelector deg) const 75 77 { 76 78 typedef typename DegreeSelector::value_type value_type;
Note: See TracChangeset
for help on using the changeset viewer.


