Changeset 3412e2


Ignore:
Timestamp:
07/18/06 01:45:50 (7 years ago)
Author:
Tiago de Paula Peixoto <tiago@…>
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)
Message:
* removed neighbour selectors (not really needed at all). Improves compilation speed, memory usage and binary size!
* removed clustering specific code in favour of more generic property code
* added GetEdgeHistogram()
* renamed some functions/options ("degree"->"vertex")


git-svn-id: https://svn.forked.de/graph-tool/trunk@9 d4600afd-f417-0410-95de-beed9576f240
Location:
src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/graph-tool

    r55cdce r3412e2  
    3636import signal 
    3737from time import * 
     38import math 
    3839 
    3940try: 
     
    8990statistics.add_option("--number-of-vertices", action="callback", callback=push_option, type="string", metavar="FILE", help="get the number of vertices") 
    9091statistics.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") 
     92statistics.add_option("--vertex-histogram", action="callback", callback=push_option, type="string", metavar="DEGREE|FILE", help="get the vertex degree/property histogram") 
     93statistics.add_option("--edge-histogram", action="callback", callback=push_option, type="string", metavar="PROPERTY|FILE", help="get the edge property histogram") 
    9294statistics.add_option("--combined-degree-histogram", action="callback", callback=push_option, type="string", metavar="FILE", help="get the combined (in,out)-degree histogram") 
    9395statistics.add_option("--average-distance", action="callback", callback=push_option, type="string", metavar="FILE", help="get the averarge distance") 
    9496statistics.add_option("--average-harmonic-distance", action="callback", callback=push_option, type="string", metavar="FILE", help="get the averarge harmonic distance") 
    9597statistics.add_option("--component-size-histogram", action="callback", callback=push_option, type="string", metavar="FILE", help="get the component size histogram") 
     98statistics.add_option("--average-vertex-property", action="callback", callback=push_option, type="string", metavar="PROPERTY|FILE", help="get the average of the vertex property") 
     99statistics.add_option("--average-edge-property", action="callback", callback=push_option, type="string", metavar="PROPERTY|FILE", help="get the average of the edge property") 
     100 
    96101 
    97102correlations =  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") 
     103correlations.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") 
     104correlations.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") 
     105correlations.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") 
    101106correlations.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") 
    102107correlations.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") 
    103108 
    104109clustering =  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") 
    107110clustering.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") 
    108111clustering.add_option("--global-clustering-coefficient", action="callback", callback=push_option, type="string", metavar="FILE", help="get the global clustering coefficient") 
     
    250253            return opt.value 
    251254        return (graph.GetComponentSizeHistogram(), opt.value) 
    252     elif opt.name == "degree-histogram": 
     255    elif opt.name == "vertex-histogram": 
    253256        values = parse_values(opt.value) 
    254257        if len(values) != 2: 
     
    257260        if just_file: 
    258261            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": 
    261271        values = parse_values(opt.value) 
    262272        if len(values) != 3: 
     
    266276        if just_file: 
    267277            return values[2] 
    268         return (graph.GetDegreeCorrelationHistogram(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": 
    270280        values = parse_values(opt.value) 
    271281        if len(values) != 4: 
     
    275285        if just_file: 
    276286            return values[3] 
    277         return (graph.GetEdgeDegreeCorrelationHistogram(deg1,values[1],deg2), values[3]) 
     287        return (graph.GetEdgeVertexCorrelationHistogram(deg1,values[1],deg2), values[3]) 
    278288    elif opt.name == "vertex-scalar-correlation-histogram": 
    279289        values = parse_values(opt.value) 
     
    284294            return values[2] 
    285295        return (graph.GetVertexDegreeScalarCorrelationHistogram(deg,values[1]),values[2]) 
    286     elif opt.name == "average-nearest-neighbours-degree": 
     296    elif opt.name == "average-nearest-neighbours-correlation": 
    287297        values = parse_values(opt.value) 
    288298        if len(values) != 3: 
     
    292302        if just_file: 
    293303            return values[2] 
    294         return (graph.GetAverageNearestNeighboursDegree(deg1,deg2), values[2]) 
     304        return (graph.GetAverageNearestNeighboursCorrelation(deg1,deg2), values[2]) 
    295305    elif opt.name == "assortativity-coefficient": 
    296306        values = parse_values(opt.value) 
     
    301311            return values[1] 
    302312        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 
    306323        for k,v in hist.iteritems(): 
    307324            avg += k*v 
     325            dev += k*k*v 
    308326            count += v 
    309327        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]) 
    317333    elif opt.name == "global-clustering-coefficient": 
    318334        if just_file: 
  • src/graph/graph.cc

    ra9aff6 r3412e2  
    226226 
    227227//============================================================================== 
    228 // get_degree_histogram 
    229 // generalized functor to obtain histogram of different types of degrees 
     228// get_vertex_histogram 
     229// generalized functor to obtain histogram of different types of "degrees" 
    230230//============================================================================== 
    231231template <class DegreeSelector> 
    232 struct get_degree_histogram 
    233 { 
    234     get_degree_histogram(DegreeSelector &deg): _degree(deg) {} 
     232struct get_vertex_histogram 
     233{ 
     234    get_vertex_histogram(DegreeSelector& deg): _degree(deg) {} 
    235235    template <class Graph, class Hist> 
    236     void operator()(const Graph &g, Hist &hist) const 
     236    void operator()(const Graph& g, Hist& hist) const 
    237237    { 
    238238    typename graph_traits<Graph>::vertex_iterator v, v_begin, v_end; 
     
    244244}; 
    245245 
    246 struct choose_degree_histogram 
    247 { 
    248     choose_degree_histogram(const GraphInterface &g, GraphInterface::deg_t deg, GraphInterface::hist_t &hist) 
     246struct choose_vertex_histogram 
     247{ 
     248    choose_vertex_histogram(const GraphInterface& g, GraphInterface::deg_t deg, GraphInterface::hist_t& hist) 
    249249    : _g(g), _hist(hist)  
    250250    { 
     
    257257    { 
    258258        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()); 
    260260    } 
    261261    } 
     
    267267 
    268268//============================================================================== 
    269 // GetDegreeHistogram(deg_type) 
    270 //============================================================================== 
    271 GraphInterface::hist_t GraphInterface::GetDegreeHistogram(GraphInterface::deg_t deg) const 
     269// GetVertexHistogram(deg_type) 
     270//============================================================================== 
     271GraphInterface::hist_t GraphInterface::GetVertexHistogram(GraphInterface::deg_t deg) const 
    272272{ 
    273273    hist_t hist; 
    274274    try  
    275275    { 
    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)); 
    277277    } 
    278278    catch (dynamic_get_failure &e) 
     
    283283    return hist; 
    284284} 
     285 
     286//============================================================================== 
     287// get_edge_histogram 
     288// generalized functor to obtain histogram of edge properties 
     289//============================================================================== 
     290struct 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//============================================================================== 
     307GraphInterface::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 
    285324 
    286325//============================================================================== 
  • src/graph/graph.hh

    r55cdce r3412e2  
    5252    }; 
    5353 
    54     enum neighbours_t 
    55     { 
    56     IN_NEIGHBOURS, 
    57     OUT_NEIGHBOURS, 
    58     ALL_NEIGHBOURS 
    59     }; 
    60  
    6154    // histogram types 
    6255    typedef std::tr1::unordered_map<double,size_t> hist_t; 
     
    7265    typedef boost::function<double (size_t jl, size_t kl, size_t j, size_t k)> corr_t; 
    7366    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); 
    7668 
    7769    // basic stats 
    7870    size_t GetNumberOfVertices() const; 
    7971    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; 
    8174 
    8275    //correlations 
    8376    hist2d_t   GetCombinedDegreeHistogram() const;     
    84     hist2d_t   GetDegreeCorrelationHistogram(deg_t degree1, deg_t degree2) const; 
    85     hist3d_t   GetEdgeDegreeCorrelationHistogram(deg_t deg1, std::string scalar, deg_t deg2) const; 
    86     hist2d_t   GetVertexDegreeScalarCorrelationHistogram(deg_t deg, std::string scalar) const; 
    87     avg_corr_t GetAverageNearestNeighboursDegree(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; 
    8881    double     GetAssortativityCoefficient(deg_t deg) const; 
    8982 
    9083    //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; 
    9486 
    9587    // other 
  • src/graph/graph_bind.cc

    ra9aff6 r3412e2  
    214214    .def("GetNumberOfVertices", &GraphInterfaceWrap::GetNumberOfVertices) 
    215215    .def("GetNumberOfEdges", &GraphInterfaceWrap::GetNumberOfEdges) 
    216     .def("GetDegreeHistogram", &GraphInterfaceWrap::GetDegreeHistogram) 
     216    .def("GetVertexHistogram", &GraphInterfaceWrap::GetVertexHistogram) 
     217    .def("GetEdgeHistogram", &GraphInterfaceWrap::GetEdgeHistogram) 
    217218    .def("GetComponentSizeHistogram", &GraphInterfaceWrap::GetComponentSizeHistogram) 
    218219    .def("GetCombinedDegreeHistogram", &GraphInterfaceWrap::GetCombinedDegreeHistogram)  
    219     .def("GetDegreeCorrelationHistogram", &GraphInterfaceWrap::GetDegreeCorrelationHistogram) 
    220     .def("GetEdgeDegreeCorrelationHistogram", &GraphInterfaceWrap::GetEdgeDegreeCorrelationHistogram) 
    221     .def("GetVertexDegreeScalarCorrelationHistogram", &GraphInterfaceWrap::GetVertexDegreeScalarCorrelationHistogram) 
    222     .def("GetAverageNearestNeighboursDegree", &GraphInterfaceWrap::GetAverageNearestNeighboursDegree) 
     220    .def("GetVertexCorrelationHistogram", &GraphInterfaceWrap::GetVertexCorrelationHistogram) 
     221    .def("GetEdgeVertexCorrelationHistogram", &GraphInterfaceWrap::GetEdgeVertexCorrelationHistogram) 
     222    .def("GetVertexScalarCorrelationHistogram", &GraphInterfaceWrap::GetVertexScalarCorrelationHistogram) 
     223    .def("GetAverageNearestNeighboursCorrelation", &GraphInterfaceWrap::GetAverageNearestNeighboursCorrelation) 
    223224    .def("GetAssortativityCoefficient", &GraphInterfaceWrap::GetAssortativityCoefficient) 
    224225    .def("GetGlobalClustering", &GraphInterfaceWrap::GetGlobalClustering) 
     
    258259    .value("Total", GraphInterfaceWrap::TOTAL_DEGREE); 
    259260 
    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  
    265261    variant_from_python<string>(); 
    266262    variant_from_python<GraphInterfaceWrap::degree_t>(); 
  • src/graph/graph_clustering.cc

    ra9aff6 r3412e2  
    9191} 
    9292 
    93 //============================================================================== 
    94 // GetClusteringHistogram() 
    95 // retrieves the distribution of local clustering coefficients 
    96 //============================================================================== 
    97  
    98 struct get_clustering_histogram 
    99 { 
    100     template <class Graph, class Hist> 
    101     void operator()(const Graph &g, Hist &hist) const 
    102     { 
    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 ug 
    109         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_graph 
    116     { 
    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_t 
    124 GraphInterface::GetLocalClusteringHistogram() const 
    125 {        
    126     hist_t hist; 
    127     check_filter(*this, bind<void>(get_clustering_histogram(), _1, var(hist)), reverse_check(), directed_check());  
    128     return hist; 
    129 } 
    13093 
    13194//============================================================================== 
     
    206169    check_filter(*this, bind<void>(set_clustering_to_property(), _1, var(clust_map)), reverse_check(), directed_check());  
    207170 
     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 
    208178    _properties.property(property, clust_map); 
    209179} 
  • src/graph/graph_correlations.cc

    ra9aff6 r3412e2  
    101101 
    102102template <class SecondDegreeSelectors> 
    103 struct choose_degree_correlation_histogram 
    104 { 
    105     choose_degree_correlation_histogram(const GraphInterface &g, GraphInterface::deg_t deg1,  
     103struct choose_vertex_correlation_histogram 
     104{ 
     105    choose_vertex_correlation_histogram(const GraphInterface &g, GraphInterface::deg_t deg1,  
    106106                    GraphInterface::deg_t deg2, GraphInterface::hist2d_t &hist) 
    107107    : _g(g), _hist(hist)  
     
    114114    struct check_second_degree 
    115115    { 
    116     check_second_degree(choose_degree_correlation_histogram<SecondDegreeSelectors> &parent):_parent(parent) {} 
     116    check_second_degree(choose_vertex_correlation_histogram<SecondDegreeSelectors> &parent):_parent(parent) {} 
    117117    template <class DegreeSelector2> 
    118118    void operator()(DegreeSelector2) 
     
    126126        } 
    127127    } 
    128     choose_degree_correlation_histogram<SecondDegreeSelectors> _parent; 
     128    choose_vertex_correlation_histogram<SecondDegreeSelectors> _parent; 
    129129    }; 
    130130 
     
    145145 
    146146GraphInterface::hist2d_t  
    147 GraphInterface::GetDegreeCorrelationHistogram(GraphInterface::deg_t deg1, GraphInterface::deg_t deg2) const 
     147GraphInterface::GetVertexCorrelationHistogram(GraphInterface::deg_t deg1, GraphInterface::deg_t deg2) const 
    148148{ 
    149149    hist2d_t hist; 
     
    151151    try  
    152152    { 
    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)); 
    154154    } 
    155155    catch (dynamic_get_failure &e) 
     
    196196 
    197197//============================================================================== 
    198 // GetEdgeDegreeCorrelationHistogram(deg1, scalar, deg2) 
     198// GetEdgeVertexCorrelationHistogram(deg1, scalar, deg2) 
    199199// retrieves the degree-edge-degree correlation histogram  
    200200//============================================================================== 
    201201 
    202202template <class SecondDegreeSelectors> 
    203 struct choose_edge_degree_correlation_histogram 
    204 { 
    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) 
     203struct 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) 
    207207    : _g(g), _edge_scalar(edge_scalar), _hist(hist)  
    208208    { 
     
    214214    struct check_second_degree 
    215215    { 
    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) {} 
    217217    template <class DegreeSelector2> 
    218218    void operator()(DegreeSelector2) 
     
    227227        } 
    228228    } 
    229     choose_edge_degree_correlation_histogram<SecondDegreeSelectors> _parent; 
     229    choose_edge_vertex_correlation_histogram<SecondDegreeSelectors> _parent; 
    230230    }; 
    231231 
     
    236236        mpl::for_each<SecondDegreeSelectors>(check_second_degree<DegreeSelector>(*this)); 
    237237    } 
    238     const GraphInterface &_g; 
     238    const GraphInterface& _g; 
    239239    scalarS& _edge_scalar; 
    240     GraphInterface::hist3d_t &_hist; 
     240    GraphInterface::hist3d_t& _hist; 
    241241    GraphInterface::degree_t _deg1; 
    242242    string _deg_name1; 
     
    246246 
    247247GraphInterface::hist3d_t  
    248 GraphInterface::GetEdgeDegreeCorrelationHistogram(GraphInterface::deg_t deg1, string edge_scalar, GraphInterface::deg_t deg2 ) const 
     248GraphInterface::GetEdgeVertexCorrelationHistogram(GraphInterface::deg_t deg1, string edge_scalar, GraphInterface::deg_t deg2) const 
    249249{ 
    250250    hist3d_t hist; 
     
    254254    { 
    255255    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) 
    259259    { 
    260260    throw GraphException("error getting scalar property: " + string(e.what())); 
     
    290290 
    291291//============================================================================== 
    292 // GetVertexDegreeScalarCorrelationHistogram(deg, scalar) 
    293 // retrieves the degree-scalar vertex correlation histogram  
    294 //============================================================================== 
    295  
    296 struct choose_vertex_degree_scalar_correlation_histogram 
    297 { 
    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 
     296struct 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) 
    300300    : _g(g), _scalar(scalar), _hist(hist)  
    301301    { 
     
    321321}; 
    322322 
    323 GraphInterface::hist2d_t GraphInterface::GetVertexDegreeScalarCorrelationHistogram(deg_t deg, string scalar) const 
     323GraphInterface::hist2d_t GraphInterface::GetVertexScalarCorrelationHistogram(deg_t deg, string scalar) const 
    324324{ 
    325325    hist2d_t hist; 
     
    329329    { 
    330330    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)); 
    332332    } 
    333333    catch (dynamic_get_failure &e) 
  • src/graph/graph_correlations_neighbours.cc

    r55cdce r3412e2  
    3535 
    3636//============================================================================== 
    37 // average_nearest_neighbours_degree 
    38 // return generalized average nearest neighbours degree 
     37// average_nearest_neighbours_correlation 
     38// return generalized average nearest neighbours correlation 
    3939//============================================================================== 
    4040 
    4141template <class DegreeSelectorOrigin, class DegreeSelectorNeighbours> 
    42 struct get_average_nearest_neighbours_degree 
     42struct get_average_nearest_neighbours_correlation 
    4343{ 
    44     get_average_nearest_neighbours_degree(DegreeSelectorOrigin& origin_deg, DegreeSelectorNeighbours& neighbours_deg) 
     44    get_average_nearest_neighbours_correlation(DegreeSelectorOrigin& origin_deg, DegreeSelectorNeighbours& neighbours_deg) 
    4545    : _origin_degree(origin_deg), _neighbours_degree(neighbours_deg) {} 
    4646 
     
    8787 
    8888template <class DegreeSelectors> 
    89 struct choose_average_nearest_neighbours_degree 
     89struct choose_average_nearest_neighbours_correlation 
    9090{ 
    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) 
    9292    : _g(g), _avg_deg(avg_deg)  
    9393    { 
     
    9999    struct choose_neighbour_degree 
    100100    { 
    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) {} 
    102102    template <class DegreeSelector> 
    103103    void operator()(DegreeSelector) 
     
    107107        OriginDegreeSelector origin_deg(_parent._origin_deg_name, _parent._g); 
    108108        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), 
    110110                            _1, var(_parent._avg_deg)), 
    111111                 reverse_check(),directed_check());  
    112112        } 
    113113    } 
    114     choose_average_nearest_neighbours_degree<DegreeSelectors> &_parent; 
     114    choose_average_nearest_neighbours_correlation<DegreeSelectors> &_parent; 
    115115    }; 
    116116 
     
    131131 
    132132//============================================================================== 
    133 // GetAverageNearestNeighboursDegree(neigh, orign_deg, neighbours_deg) 
     133// GetAverageNearestNeighboursCorrelation(neigh, orign_deg, neighbours_deg) 
    134134//============================================================================== 
    135135GraphInterface::avg_corr_t 
    136 GraphInterface::GetAverageNearestNeighboursDegree(deg_t origin_deg, deg_t neighbours_deg ) const 
     136GraphInterface::GetAverageNearestNeighboursCorrelation(deg_t origin_deg, deg_t neighbours_deg ) const 
    137137{ 
    138138    GraphInterface::avg_corr_t avg_corr; 
     
    141141    { 
    142142    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)); 
    144144    } 
    145145    catch (dynamic_get_failure &e) 
  • src/graph/graph_properties.cc

    ra9aff6 r3412e2  
    2323//============================================================================== 
    2424boost::dynamic_property_map&  
    25 graph_tool::find_property_map(boost::dynamic_properties& dp, std::string name, const std::type_info& key_type) 
     25graph_tool::find_property_map(const boost::dynamic_properties& dp, std::string name, const std::type_info& key_type) 
    2626{ 
    2727    for(typeof(dp.begin()) iter = dp.begin(); iter != dp.end(); ++iter) 
  • src/graph/graph_properties.hh

    ra9aff6 r3412e2  
    3636} 
    3737 
    38 boost::dynamic_property_map& find_property_map(boost::dynamic_properties& dp, std::string name, const std::type_info& key_type); 
     38boost::dynamic_property_map& find_property_map(const boost::dynamic_properties& dp, std::string name, const std::type_info& key_type); 
    3939 
    4040struct dynamic_properties_copy: public boost::dynamic_properties 
  • src/graph/graph_selectors.hh

    r55cdce r3412e2  
    105105    scalarS(std::string scalar_property, const GraphInterface& g):  
    106106    _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; 
    108108    template <class Graph, class VertexOrEdge>  
    109109    double operator()(const VertexOrEdge& v, const Graph &g) const  
Note: See TracChangeset for help on using the changeset viewer.