Changeset 3412e2
- Timestamp:
- 07/18/06 01:45:50 (7 years ago)
- Branches:
- master, python3
- Children:
- 479e4d
- Parents:
- 8f3424
- git-author:
- Tiago de Paula Peixoto <tiago@…> (07/18/06 01:45:50)
- git-committer:
- Tiago de Paula Peixoto <tiago@…> (07/18/06 01:45:50)
- Location:
- src
- Files:
-
- 10 edited
-
graph-tool (modified) (9 diffs)
-
graph/graph.cc (modified) (5 diffs)
-
graph/graph.hh (modified) (2 diffs)
-
graph/graph_bind.cc (modified) (2 diffs)
-
graph/graph_clustering.cc (modified) (2 diffs)
-
graph/graph_correlations.cc (modified) (14 diffs)
-
graph/graph_correlations_neighbours.cc (modified) (6 diffs)
-
graph/graph_properties.cc (modified) (1 diff)
-
graph/graph_properties.hh (modified) (1 diff)
-
graph/graph_selectors.hh (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/graph-tool
r55cdce r3412e2 36 36 import signal 37 37 from time import * 38 import math 38 39 39 40 try: … … 89 90 statistics.add_option("--number-of-vertices", action="callback", callback=push_option, type="string", metavar="FILE", help="get the number of vertices") 90 91 statistics.add_option("--number-of-edges", action="callback", callback=push_option, type="string", metavar="FILE", help="get the number of edges") 91 statistics.add_option("--degree-histogram", action="callback", callback=push_option, type="string", metavar="DEGREE|FILE", help="get the degree histogram") 92 statistics.add_option("--vertex-histogram", action="callback", callback=push_option, type="string", metavar="DEGREE|FILE", help="get the vertex degree/property histogram") 93 statistics.add_option("--edge-histogram", action="callback", callback=push_option, type="string", metavar="PROPERTY|FILE", help="get the edge property histogram") 92 94 statistics.add_option("--combined-degree-histogram", action="callback", callback=push_option, type="string", metavar="FILE", help="get the combined (in,out)-degree histogram") 93 95 statistics.add_option("--average-distance", action="callback", callback=push_option, type="string", metavar="FILE", help="get the averarge distance") 94 96 statistics.add_option("--average-harmonic-distance", action="callback", callback=push_option, type="string", metavar="FILE", help="get the averarge harmonic distance") 95 97 statistics.add_option("--component-size-histogram", action="callback", callback=push_option, type="string", metavar="FILE", help="get the component size histogram") 98 statistics.add_option("--average-vertex-property", action="callback", callback=push_option, type="string", metavar="PROPERTY|FILE", help="get the average of the vertex property") 99 statistics.add_option("--average-edge-property", action="callback", callback=push_option, type="string", metavar="PROPERTY|FILE", help="get the average of the edge property") 100 96 101 97 102 correlations = parser.add_option_group("Correlations") 98 correlations.add_option("-- degree-correlation-histogram", action="callback", callback=push_option, type="string", metavar="DEGREE1|DEGREE2|FILE", help="get the degree correlation histogram. Scalar properties are also accepted in place of DEGREE")99 correlations.add_option("--average-nearest-neighbours- degree", action="callback", callback=push_option, type="string", metavar="ORIGIN-DEGREE|DEGREE|FILE", help="get the average nearest neighbours degree")100 correlations.add_option("--edge- degree-correlation-histogram", action="callback", callback=push_option, type="string", metavar="DEGREE1|EDGE-PROP|DEGREE2|FILE", help="get the source degree vs. edge scalar vs. target degree correlation histogram. Scalar properties are also accepted in place of DEGREE-TYPE")103 correlations.add_option("--vertex-correlation-histogram", action="callback", callback=push_option, type="string", metavar="DEGREE1|DEGREE2|FILE", help="get the degree correlation histogram. Scalar properties are also accepted in place of DEGREE") 104 correlations.add_option("--average-nearest-neighbours-correlation", action="callback", callback=push_option, type="string", metavar="ORIGIN-DEGREE|DEGREE|FILE", help="get the average nearest neighbours correlation") 105 correlations.add_option("--edge-vertex-correlation-histogram", action="callback", callback=push_option, type="string", metavar="DEGREE1|EDGE-PROP|DEGREE2|FILE", help="get the source degree vs. edge scalar vs. target degree correlation histogram. Scalar properties are also accepted in place of DEGREE-TYPE") 101 106 correlations.add_option("--vertex-scalar-correlation-histogram", action="callback", callback=push_option, type="string", metavar="DEGREE|VERTEX-PROP|FILE", help="get the degree vs. vertex scalar correlation histogram. Scalar properties are also accepted in place of DEGREE") 102 107 correlations.add_option("--assortativity-coefficient", action="callback", callback=push_option, type="string", metavar="DEGREE|FILE", help="get the assortativity coefficient. Scalar properties are also accepted in place of DEGREE") 103 108 104 109 clustering = parser.add_option_group("Clustering") 105 clustering.add_option("--local-clustering-coefficient", action="callback", callback=push_option, type="string", metavar="FILE", help="get the local clustering coefficient")106 clustering.add_option("--local-clustering-coefficient-histogram", action="callback", callback=push_option, type="string", metavar="DEGREE_TYPE|FILE", help="get the local clustering coefficient histogram")107 110 clustering.add_option("--set-local-clustering-to-property", action="callback", callback=push_option, type="string", metavar="PROPERTY", help="set the local clustering coefficient to vertex property") 108 111 clustering.add_option("--global-clustering-coefficient", action="callback", callback=push_option, type="string", metavar="FILE", help="get the global clustering coefficient") … … 250 253 return opt.value 251 254 return (graph.GetComponentSizeHistogram(), opt.value) 252 elif opt.name == " degree-histogram":255 elif opt.name == "vertex-histogram": 253 256 values = parse_values(opt.value) 254 257 if len(values) != 2: … … 257 260 if just_file: 258 261 return values[1] 259 return (graph.GetDegreeHistogram(deg), values[1]) 260 elif opt.name == "degree-correlation-histogram": 262 return (graph.GetVertexHistogram(deg), values[1]) 263 elif opt.name == "edge-histogram": 264 values = parse_values(opt.value) 265 if len(values) != 2: 266 raise OptionError(opt.name, "invalid value '%s'" % opt.value) 267 if just_file: 268 return values[1] 269 return (graph.GetEdgeHistogram(values[0]), values[1]) 270 elif opt.name == "vertex-correlation-histogram": 261 271 values = parse_values(opt.value) 262 272 if len(values) != 3: … … 266 276 if just_file: 267 277 return values[2] 268 return (graph.Get DegreeCorrelationHistogram(deg1,deg2), values[2])269 elif opt.name == "edge- degree-correlation-histogram":278 return (graph.GetVertexCorrelationHistogram(deg1,deg2), values[2]) 279 elif opt.name == "edge-vertex-correlation-histogram": 270 280 values = parse_values(opt.value) 271 281 if len(values) != 4: … … 275 285 if just_file: 276 286 return values[3] 277 return (graph.GetEdge DegreeCorrelationHistogram(deg1,values[1],deg2), values[3])287 return (graph.GetEdgeVertexCorrelationHistogram(deg1,values[1],deg2), values[3]) 278 288 elif opt.name == "vertex-scalar-correlation-histogram": 279 289 values = parse_values(opt.value) … … 284 294 return values[2] 285 295 return (graph.GetVertexDegreeScalarCorrelationHistogram(deg,values[1]),values[2]) 286 elif opt.name == "average-nearest-neighbours- degree":296 elif opt.name == "average-nearest-neighbours-correlation": 287 297 values = parse_values(opt.value) 288 298 if len(values) != 3: … … 292 302 if just_file: 293 303 return values[2] 294 return (graph.GetAverageNearestNeighbours Degree(deg1,deg2), values[2])304 return (graph.GetAverageNearestNeighboursCorrelation(deg1,deg2), values[2]) 295 305 elif opt.name == "assortativity-coefficient": 296 306 values = parse_values(opt.value) … … 301 311 return values[1] 302 312 return (graph.GetAssortativityCoefficient(deg), values[1]) 303 elif opt.name == "local-clustering-coefficient": 304 hist = graph.GetLocalClusteringHistogram() 305 avg,count = 0.0,0.0 313 elif opt.name == "average-vertex-property" or opt.name == "average-edge-property": 314 values = parse_values(opt.value) 315 if len(values) != 2: 316 raise OptionError(opt.name, "invalid value '%s'" % opt.value) 317 if opt.name == "average-vertex-property": 318 deg = degree(values[0]) 319 hist = graph.GetVertexHistogram(deg) 320 else: 321 hist = graph.GetEdgeHistogram(values[0]) 322 avg,dev,count = 0.0,0.0,0.0 306 323 for k,v in hist.iteritems(): 307 324 avg += k*v 325 dev += k*k*v 308 326 count += v 309 327 avg /= count 310 if just_file: 311 return opt.value 312 return (avg,opt.value) 313 elif opt.name == "local-clustering-coefficiet-histogram": 314 if just_file: 315 return opt.value 316 return (graph.GetLocalClusteringHistogram(), opt.value) 328 dev = math.sqrt(dev/count - avg*avg)/math.sqrt(count) 329 ret = "%f\t%f" % (avg, dev) 330 if just_file: 331 return values[1] 332 return (ret,values[1]) 317 333 elif opt.name == "global-clustering-coefficient": 318 334 if just_file: -
src/graph/graph.cc
ra9aff6 r3412e2 226 226 227 227 //============================================================================== 228 // get_ degree_histogram229 // generalized functor to obtain histogram of different types of degrees228 // get_vertex_histogram 229 // generalized functor to obtain histogram of different types of "degrees" 230 230 //============================================================================== 231 231 template <class DegreeSelector> 232 struct get_ degree_histogram233 { 234 get_ degree_histogram(DegreeSelector °): _degree(deg) {}232 struct get_vertex_histogram 233 { 234 get_vertex_histogram(DegreeSelector& deg): _degree(deg) {} 235 235 template <class Graph, class Hist> 236 void operator()(const Graph &g, Hist &hist) const236 void operator()(const Graph& g, Hist& hist) const 237 237 { 238 238 typename graph_traits<Graph>::vertex_iterator v, v_begin, v_end; … … 244 244 }; 245 245 246 struct choose_ degree_histogram247 { 248 choose_ degree_histogram(const GraphInterface &g, GraphInterface::deg_t deg, GraphInterface::hist_t &hist)246 struct choose_vertex_histogram 247 { 248 choose_vertex_histogram(const GraphInterface& g, GraphInterface::deg_t deg, GraphInterface::hist_t& hist) 249 249 : _g(g), _hist(hist) 250 250 { … … 257 257 { 258 258 DegreeSelector selector(_deg_name, _g); 259 check_filter(_g, bind<void>(get_ degree_histogram<DegreeSelector>(selector), _1, var(_hist)),reverse_check(),directed_check());259 check_filter(_g, bind<void>(get_vertex_histogram<DegreeSelector>(selector), _1, var(_hist)),reverse_check(),directed_check()); 260 260 } 261 261 } … … 267 267 268 268 //============================================================================== 269 // Get DegreeHistogram(deg_type)270 //============================================================================== 271 GraphInterface::hist_t GraphInterface::Get DegreeHistogram(GraphInterface::deg_t deg) const269 // GetVertexHistogram(deg_type) 270 //============================================================================== 271 GraphInterface::hist_t GraphInterface::GetVertexHistogram(GraphInterface::deg_t deg) const 272 272 { 273 273 hist_t hist; 274 274 try 275 275 { 276 mpl::for_each<mpl::vector<in_degreeS, out_degreeS, total_degreeS, scalarS> >(choose_ degree_histogram(*this, deg, hist));276 mpl::for_each<mpl::vector<in_degreeS, out_degreeS, total_degreeS, scalarS> >(choose_vertex_histogram(*this, deg, hist)); 277 277 } 278 278 catch (dynamic_get_failure &e) … … 283 283 return hist; 284 284 } 285 286 //============================================================================== 287 // get_edge_histogram 288 // generalized functor to obtain histogram of edge properties 289 //============================================================================== 290 struct get_edge_histogram 291 { 292 get_edge_histogram(scalarS& prop): _prop(prop) {} 293 template <class Graph, class Hist> 294 void operator()(const Graph& g, Hist& hist) const 295 { 296 typename graph_traits<Graph>::edge_iterator e, e_begin, e_end; 297 tie(e_begin, e_end) = edges(g); 298 for(e = e_begin; e != e_end; ++e) 299 hist[_prop(*e,g)]++; 300 } 301 scalarS& _prop; 302 }; 303 304 //============================================================================== 305 // GetEdgeHistogram(property) 306 //============================================================================== 307 GraphInterface::hist_t GraphInterface::GetEdgeHistogram(string property) const 308 { 309 hist_t hist; 310 try 311 { 312 scalarS prop(property, *this); 313 check_filter(*this, bind<void>(get_edge_histogram(prop), _1, var(hist)),reverse_check(),directed_check()); 314 } 315 catch (dynamic_get_failure &e) 316 { 317 throw GraphException("error getting scalar property: " + string(e.what())); 318 } 319 320 321 return hist; 322 } 323 285 324 286 325 //============================================================================== -
src/graph/graph.hh
r55cdce r3412e2 52 52 }; 53 53 54 enum neighbours_t55 {56 IN_NEIGHBOURS,57 OUT_NEIGHBOURS,58 ALL_NEIGHBOURS59 };60 61 54 // histogram types 62 55 typedef std::tr1::unordered_map<double,size_t> hist_t; … … 72 65 typedef boost::function<double (size_t jl, size_t kl, size_t j, size_t k)> corr_t; 73 66 typedef boost::function<std::pair<size_t,size_t> (double r1, double r2, size_t j, size_t k)> inv_corr_t; 74 void GenerateCorrelatedConfigurationalModel(size_t N, pjk_t p, pjk_t ceil, inv_ceil_t inv_ceil, double ceil_pjk_bound, corr_t corr, corr_t ceil_corr, 75 inv_corr_t inv_ceil_corr, double ceil_corr_bound, bool undirected_corr, size_t seed, bool verbose); 67 void GenerateCorrelatedConfigurationalModel(size_t N, pjk_t p, pjk_t ceil, inv_ceil_t inv_ceil, double ceil_pjk_bound, corr_t corr, corr_t ceil_corr, inv_corr_t inv_ceil_corr, double ceil_corr_bound, bool undirected_corr, size_t seed, bool verbose); 76 68 77 69 // basic stats 78 70 size_t GetNumberOfVertices() const; 79 71 size_t GetNumberOfEdges() const; 80 hist_t GetDegreeHistogram(deg_t degree) const; 72 hist_t GetVertexHistogram(deg_t degree) const; 73 hist_t GetEdgeHistogram(std::string property) const; 81 74 82 75 //correlations 83 76 hist2d_t GetCombinedDegreeHistogram() const; 84 hist2d_t Get DegreeCorrelationHistogram(deg_t degree1, deg_t degree2) const;85 hist3d_t GetEdge DegreeCorrelationHistogram(deg_t deg1, std::string scalar, deg_t deg2) const;86 hist2d_t GetVertex DegreeScalarCorrelationHistogram(deg_t deg, std::string scalar) const;87 avg_corr_t GetAverageNearestNeighbours Degree(deg_t origin_degree, deg_t neighbour_degree) const;77 hist2d_t GetVertexCorrelationHistogram(deg_t degree1, deg_t degree2) const; 78 hist3d_t GetEdgeVertexCorrelationHistogram(deg_t deg1, std::string scalar, deg_t deg2) const; 79 hist2d_t GetVertexScalarCorrelationHistogram(deg_t deg, std::string scalar) const; 80 avg_corr_t GetAverageNearestNeighboursCorrelation(deg_t origin_degree, deg_t neighbour_degree) const; 88 81 double GetAssortativityCoefficient(deg_t deg) const; 89 82 90 83 //clustering 91 hist_t GetLocalClusteringHistogram() const; 92 void SetLocalClusteringToProperty(std::string property); 93 double GetGlobalClustering() const; 84 void SetLocalClusteringToProperty(std::string property); 85 double GetGlobalClustering() const; 94 86 95 87 // other -
src/graph/graph_bind.cc
ra9aff6 r3412e2 214 214 .def("GetNumberOfVertices", &GraphInterfaceWrap::GetNumberOfVertices) 215 215 .def("GetNumberOfEdges", &GraphInterfaceWrap::GetNumberOfEdges) 216 .def("GetDegreeHistogram", &GraphInterfaceWrap::GetDegreeHistogram) 216 .def("GetVertexHistogram", &GraphInterfaceWrap::GetVertexHistogram) 217 .def("GetEdgeHistogram", &GraphInterfaceWrap::GetEdgeHistogram) 217 218 .def("GetComponentSizeHistogram", &GraphInterfaceWrap::GetComponentSizeHistogram) 218 219 .def("GetCombinedDegreeHistogram", &GraphInterfaceWrap::GetCombinedDegreeHistogram) 219 .def("Get DegreeCorrelationHistogram", &GraphInterfaceWrap::GetDegreeCorrelationHistogram)220 .def("GetEdge DegreeCorrelationHistogram", &GraphInterfaceWrap::GetEdgeDegreeCorrelationHistogram)221 .def("GetVertex DegreeScalarCorrelationHistogram", &GraphInterfaceWrap::GetVertexDegreeScalarCorrelationHistogram)222 .def("GetAverageNearestNeighbours Degree", &GraphInterfaceWrap::GetAverageNearestNeighboursDegree)220 .def("GetVertexCorrelationHistogram", &GraphInterfaceWrap::GetVertexCorrelationHistogram) 221 .def("GetEdgeVertexCorrelationHistogram", &GraphInterfaceWrap::GetEdgeVertexCorrelationHistogram) 222 .def("GetVertexScalarCorrelationHistogram", &GraphInterfaceWrap::GetVertexScalarCorrelationHistogram) 223 .def("GetAverageNearestNeighboursCorrelation", &GraphInterfaceWrap::GetAverageNearestNeighboursCorrelation) 223 224 .def("GetAssortativityCoefficient", &GraphInterfaceWrap::GetAssortativityCoefficient) 224 225 .def("GetGlobalClustering", &GraphInterfaceWrap::GetGlobalClustering) … … 258 259 .value("Total", GraphInterfaceWrap::TOTAL_DEGREE); 259 260 260 enum_<GraphInterfaceWrap::neighbours_t>("Neighbours")261 .value("In", GraphInterfaceWrap::IN_NEIGHBOURS)262 .value("Out", GraphInterfaceWrap::OUT_NEIGHBOURS)263 .value("All", GraphInterfaceWrap::ALL_NEIGHBOURS);264 265 261 variant_from_python<string>(); 266 262 variant_from_python<GraphInterfaceWrap::degree_t>(); -
src/graph/graph_clustering.cc
ra9aff6 r3412e2 91 91 } 92 92 93 //==============================================================================94 // GetClusteringHistogram()95 // retrieves the distribution of local clustering coefficients96 //==============================================================================97 98 struct get_clustering_histogram99 {100 template <class Graph, class Hist>101 void operator()(const Graph &g, Hist &hist) const102 {103 typename get_undirected_graph<Graph>::type ug(g);104 typename graph_traits<Graph>::vertex_iterator v, v_begin, v_end;105 tie(v_begin, v_end) = vertices(g);106 for(v = v_begin; v != v_end; ++v)107 {108 pair<size_t,size_t> triangles = get_triangles(*v,ug); // get from ug109 double clustering = (triangles.second > 0)?double(triangles.first)/triangles.second:0.0;110 hist[clustering]++;111 }112 }113 114 template <class Graph>115 struct get_undirected_graph116 {117 typedef typename mpl::if_< is_convertible<typename graph_traits<Graph>::directed_category, directed_tag>,118 const UndirectedAdaptor<Graph>,119 const Graph& >::type type;120 };121 };122 123 GraphInterface::hist_t124 GraphInterface::GetLocalClusteringHistogram() const125 {126 hist_t hist;127 check_filter(*this, bind<void>(get_clustering_histogram(), _1, var(hist)), reverse_check(), directed_check());128 return hist;129 }130 93 131 94 //============================================================================== … … 206 169 check_filter(*this, bind<void>(set_clustering_to_property(), _1, var(clust_map)), reverse_check(), directed_check()); 207 170 171 try 172 { 173 find_property_map(_properties, property, typeid(graph_traits<multigraph_t>::vertex_descriptor)); 174 RemoveVertexProperty(property); 175 } 176 catch (property_not_found) {} 177 208 178 _properties.property(property, clust_map); 209 179 } -
src/graph/graph_correlations.cc
ra9aff6 r3412e2 101 101 102 102 template <class SecondDegreeSelectors> 103 struct choose_ degree_correlation_histogram104 { 105 choose_ degree_correlation_histogram(const GraphInterface &g, GraphInterface::deg_t deg1,103 struct choose_vertex_correlation_histogram 104 { 105 choose_vertex_correlation_histogram(const GraphInterface &g, GraphInterface::deg_t deg1, 106 106 GraphInterface::deg_t deg2, GraphInterface::hist2d_t &hist) 107 107 : _g(g), _hist(hist) … … 114 114 struct check_second_degree 115 115 { 116 check_second_degree(choose_ degree_correlation_histogram<SecondDegreeSelectors> &parent):_parent(parent) {}116 check_second_degree(choose_vertex_correlation_histogram<SecondDegreeSelectors> &parent):_parent(parent) {} 117 117 template <class DegreeSelector2> 118 118 void operator()(DegreeSelector2) … … 126 126 } 127 127 } 128 choose_ degree_correlation_histogram<SecondDegreeSelectors> _parent;128 choose_vertex_correlation_histogram<SecondDegreeSelectors> _parent; 129 129 }; 130 130 … … 145 145 146 146 GraphInterface::hist2d_t 147 GraphInterface::Get DegreeCorrelationHistogram(GraphInterface::deg_t deg1, GraphInterface::deg_t deg2) const147 GraphInterface::GetVertexCorrelationHistogram(GraphInterface::deg_t deg1, GraphInterface::deg_t deg2) const 148 148 { 149 149 hist2d_t hist; … … 151 151 try 152 152 { 153 mpl::for_each<degree_selectors>(choose_ degree_correlation_histogram<degree_selectors>(*this, deg1, deg2, hist));153 mpl::for_each<degree_selectors>(choose_vertex_correlation_histogram<degree_selectors>(*this, deg1, deg2, hist)); 154 154 } 155 155 catch (dynamic_get_failure &e) … … 196 196 197 197 //============================================================================== 198 // GetEdge DegreeCorrelationHistogram(deg1, scalar, deg2)198 // GetEdgeVertexCorrelationHistogram(deg1, scalar, deg2) 199 199 // retrieves the degree-edge-degree correlation histogram 200 200 //============================================================================== 201 201 202 202 template <class SecondDegreeSelectors> 203 struct choose_edge_ degree_correlation_histogram204 { 205 choose_edge_ degree_correlation_histogram(const GraphInterface &g, GraphInterface::deg_t deg1, scalarS& edge_scalar,206 GraphInterface::deg_t deg2, GraphInterface::hist3d_t &hist)203 struct choose_edge_vertex_correlation_histogram 204 { 205 choose_edge_vertex_correlation_histogram(const GraphInterface& g, GraphInterface::deg_t deg1, scalarS& edge_scalar, 206 GraphInterface::deg_t deg2, GraphInterface::hist3d_t& hist) 207 207 : _g(g), _edge_scalar(edge_scalar), _hist(hist) 208 208 { … … 214 214 struct check_second_degree 215 215 { 216 check_second_degree(choose_edge_ degree_correlation_histogram<SecondDegreeSelectors> &parent):_parent(parent) {}216 check_second_degree(choose_edge_vertex_correlation_histogram<SecondDegreeSelectors> &parent):_parent(parent) {} 217 217 template <class DegreeSelector2> 218 218 void operator()(DegreeSelector2) … … 227 227 } 228 228 } 229 choose_edge_ degree_correlation_histogram<SecondDegreeSelectors> _parent;229 choose_edge_vertex_correlation_histogram<SecondDegreeSelectors> _parent; 230 230 }; 231 231 … … 236 236 mpl::for_each<SecondDegreeSelectors>(check_second_degree<DegreeSelector>(*this)); 237 237 } 238 const GraphInterface &_g;238 const GraphInterface& _g; 239 239 scalarS& _edge_scalar; 240 GraphInterface::hist3d_t &_hist;240 GraphInterface::hist3d_t& _hist; 241 241 GraphInterface::degree_t _deg1; 242 242 string _deg_name1; … … 246 246 247 247 GraphInterface::hist3d_t 248 GraphInterface::GetEdge DegreeCorrelationHistogram(GraphInterface::deg_t deg1, string edge_scalar, GraphInterface::deg_t deg2) const248 GraphInterface::GetEdgeVertexCorrelationHistogram(GraphInterface::deg_t deg1, string edge_scalar, GraphInterface::deg_t deg2) const 249 249 { 250 250 hist3d_t hist; … … 254 254 { 255 255 typedef mpl::vector<in_degreeS, out_degreeS, total_degreeS, scalarS> degree_selectors; 256 mpl::for_each<degree_selectors>(choose_edge_ degree_correlation_histogram<degree_selectors>(*this, deg1, scalar, deg2, hist));257 } 258 catch (dynamic_get_failure &e)256 mpl::for_each<degree_selectors>(choose_edge_vertex_correlation_histogram<degree_selectors>(*this, deg1, scalar, deg2, hist)); 257 } 258 catch (dynamic_get_failure& e) 259 259 { 260 260 throw GraphException("error getting scalar property: " + string(e.what())); … … 290 290 291 291 //============================================================================== 292 // GetVertex DegreeScalarCorrelationHistogram(deg, scalar)293 // retrieves the degree-scalar vertexcorrelation histogram294 //============================================================================== 295 296 struct choose_vertex_ degree_scalar_correlation_histogram297 { 298 choose_vertex_ degree_scalar_correlation_histogram(const GraphInterface &g, GraphInterface::deg_t deg, scalarS& scalar,299 GraphInterface::hist2d_t &hist)292 // GetVertexScalarCorrelationHistogram(deg, scalar) 293 // retrieves the vertex-scalar correlation histogram 294 //============================================================================== 295 296 struct choose_vertex_scalar_correlation_histogram 297 { 298 choose_vertex_scalar_correlation_histogram(const GraphInterface& g, GraphInterface::deg_t deg, scalarS& scalar, 299 GraphInterface::hist2d_t& hist) 300 300 : _g(g), _scalar(scalar), _hist(hist) 301 301 { … … 321 321 }; 322 322 323 GraphInterface::hist2d_t GraphInterface::GetVertex DegreeScalarCorrelationHistogram(deg_t deg, string scalar) const323 GraphInterface::hist2d_t GraphInterface::GetVertexScalarCorrelationHistogram(deg_t deg, string scalar) const 324 324 { 325 325 hist2d_t hist; … … 329 329 { 330 330 typedef mpl::vector<in_degreeS, out_degreeS, total_degreeS, scalarS> degree_selectors; 331 mpl::for_each<degree_selectors>(choose_vertex_ degree_scalar_correlation_histogram(*this, deg, scalar_sel, hist));331 mpl::for_each<degree_selectors>(choose_vertex_scalar_correlation_histogram(*this, deg, scalar_sel, hist)); 332 332 } 333 333 catch (dynamic_get_failure &e) -
src/graph/graph_correlations_neighbours.cc
r55cdce r3412e2 35 35 36 36 //============================================================================== 37 // average_nearest_neighbours_ degree38 // return generalized average nearest neighbours degree37 // average_nearest_neighbours_correlation 38 // return generalized average nearest neighbours correlation 39 39 //============================================================================== 40 40 41 41 template <class DegreeSelectorOrigin, class DegreeSelectorNeighbours> 42 struct get_average_nearest_neighbours_ degree42 struct get_average_nearest_neighbours_correlation 43 43 { 44 get_average_nearest_neighbours_ degree(DegreeSelectorOrigin& origin_deg, DegreeSelectorNeighbours& neighbours_deg)44 get_average_nearest_neighbours_correlation(DegreeSelectorOrigin& origin_deg, DegreeSelectorNeighbours& neighbours_deg) 45 45 : _origin_degree(origin_deg), _neighbours_degree(neighbours_deg) {} 46 46 … … 87 87 88 88 template <class DegreeSelectors> 89 struct choose_average_nearest_neighbours_ degree89 struct choose_average_nearest_neighbours_correlation 90 90 { 91 choose_average_nearest_neighbours_ degree(const GraphInterface &g, GraphInterface::deg_t origin_deg, GraphInterface::deg_t neighbour_deg, GraphInterface::avg_corr_t &avg_deg)91 choose_average_nearest_neighbours_correlation(const GraphInterface &g, GraphInterface::deg_t origin_deg, GraphInterface::deg_t neighbour_deg, GraphInterface::avg_corr_t &avg_deg) 92 92 : _g(g), _avg_deg(avg_deg) 93 93 { … … 99 99 struct choose_neighbour_degree 100 100 { 101 choose_neighbour_degree(choose_average_nearest_neighbours_ degree<DegreeSelectors>& parent):_parent(parent) {}101 choose_neighbour_degree(choose_average_nearest_neighbours_correlation<DegreeSelectors>& parent):_parent(parent) {} 102 102 template <class DegreeSelector> 103 103 void operator()(DegreeSelector) … … 107 107 OriginDegreeSelector origin_deg(_parent._origin_deg_name, _parent._g); 108 108 DegreeSelector deg(_parent._neighbour_deg_name, _parent._g); 109 check_filter(_parent._g, bind<void>(get_average_nearest_neighbours_ degree<OriginDegreeSelector,DegreeSelector>(origin_deg, deg),109 check_filter(_parent._g, bind<void>(get_average_nearest_neighbours_correlation<OriginDegreeSelector,DegreeSelector>(origin_deg, deg), 110 110 _1, var(_parent._avg_deg)), 111 111 reverse_check(),directed_check()); 112 112 } 113 113 } 114 choose_average_nearest_neighbours_ degree<DegreeSelectors> &_parent;114 choose_average_nearest_neighbours_correlation<DegreeSelectors> &_parent; 115 115 }; 116 116 … … 131 131 132 132 //============================================================================== 133 // GetAverageNearestNeighbours Degree(neigh, orign_deg, neighbours_deg)133 // GetAverageNearestNeighboursCorrelation(neigh, orign_deg, neighbours_deg) 134 134 //============================================================================== 135 135 GraphInterface::avg_corr_t 136 GraphInterface::GetAverageNearestNeighbours Degree(deg_t origin_deg, deg_t neighbours_deg ) const136 GraphInterface::GetAverageNearestNeighboursCorrelation(deg_t origin_deg, deg_t neighbours_deg ) const 137 137 { 138 138 GraphInterface::avg_corr_t avg_corr; … … 141 141 { 142 142 typedef mpl::vector<in_degreeS,out_degreeS,total_degreeS,scalarS> degrees; 143 mpl::for_each<degrees>(choose_average_nearest_neighbours_ degree<degrees>(*this, origin_deg, neighbours_deg, avg_corr));143 mpl::for_each<degrees>(choose_average_nearest_neighbours_correlation<degrees>(*this, origin_deg, neighbours_deg, avg_corr)); 144 144 } 145 145 catch (dynamic_get_failure &e) -
src/graph/graph_properties.cc
ra9aff6 r3412e2 23 23 //============================================================================== 24 24 boost::dynamic_property_map& 25 graph_tool::find_property_map( boost::dynamic_properties& dp, std::string name, const std::type_info& key_type)25 graph_tool::find_property_map(const boost::dynamic_properties& dp, std::string name, const std::type_info& key_type) 26 26 { 27 27 for(typeof(dp.begin()) iter = dp.begin(); iter != dp.end(); ++iter) -
src/graph/graph_properties.hh
ra9aff6 r3412e2 36 36 } 37 37 38 boost::dynamic_property_map& find_property_map( boost::dynamic_properties& dp, std::string name, const std::type_info& key_type);38 boost::dynamic_property_map& find_property_map(const boost::dynamic_properties& dp, std::string name, const std::type_info& key_type); 39 39 40 40 struct dynamic_properties_copy: public boost::dynamic_properties -
src/graph/graph_selectors.hh
r55cdce r3412e2 105 105 scalarS(std::string scalar_property, const GraphInterface& g): 106 106 _scalar_property(scalar_property), _g(&g) {} 107 typedef boost::mpl::vector< long double,double,float,long,unsigned long,int,unsigned int,short,unsigned short,char,unsigned char,bool,std::string> scalar_types;107 typedef boost::mpl::vector<double,long double,float,long,unsigned long,int,unsigned int,short,unsigned short,char,unsigned char,bool,std::string> scalar_types; 108 108 template <class Graph, class VertexOrEdge> 109 109 double operator()(const VertexOrEdge& v, const Graph &g) const
Note: See TracChangeset
for help on using the changeset viewer.


