Commit 3412e2df authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

* removed neighbour selectors (not really needed at all). Improves compilation...

* 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
parent 8f3424de
......@@ -35,6 +35,7 @@ import string
import time
import signal
from time import *
import math
try:
import psyco
......@@ -88,22 +89,24 @@ modification.add_option("--remove-parallel-edges", action="callback", callback=p
statistics = parser.add_option_group("Basic Statistics")
statistics.add_option("--number-of-vertices", action="callback", callback=push_option, type="string", metavar="FILE", help="get the number of vertices")
statistics.add_option("--number-of-edges", action="callback", callback=push_option, type="string", metavar="FILE", help="get the number of edges")
statistics.add_option("--degree-histogram", action="callback", callback=push_option, type="string", metavar="DEGREE|FILE", help="get the degree histogram")
statistics.add_option("--vertex-histogram", action="callback", callback=push_option, type="string", metavar="DEGREE|FILE", help="get the vertex degree/property histogram")
statistics.add_option("--edge-histogram", action="callback", callback=push_option, type="string", metavar="PROPERTY|FILE", help="get the edge property histogram")
statistics.add_option("--combined-degree-histogram", action="callback", callback=push_option, type="string", metavar="FILE", help="get the combined (in,out)-degree histogram")
statistics.add_option("--average-distance", action="callback", callback=push_option, type="string", metavar="FILE", help="get the averarge distance")
statistics.add_option("--average-harmonic-distance", action="callback", callback=push_option, type="string", metavar="FILE", help="get the averarge harmonic distance")
statistics.add_option("--component-size-histogram", action="callback", callback=push_option, type="string", metavar="FILE", help="get the component size histogram")
statistics.add_option("--average-vertex-property", action="callback", callback=push_option, type="string", metavar="PROPERTY|FILE", help="get the average of the vertex property")
statistics.add_option("--average-edge-property", action="callback", callback=push_option, type="string", metavar="PROPERTY|FILE", help="get the average of the edge property")
correlations = parser.add_option_group("Correlations")
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")
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")
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")
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")
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")
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")
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")
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")
clustering = parser.add_option_group("Clustering")
clustering.add_option("--local-clustering-coefficient", action="callback", callback=push_option, type="string", metavar="FILE", help="get the local clustering coefficient")
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")
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")
clustering.add_option("--global-clustering-coefficient", action="callback", callback=push_option, type="string", metavar="FILE", help="get the global clustering coefficient")
......@@ -249,15 +252,22 @@ def parse_option(opt, just_file=False):
if just_file:
return opt.value
return (graph.GetComponentSizeHistogram(), opt.value)
elif opt.name == "degree-histogram":
elif opt.name == "vertex-histogram":
values = parse_values(opt.value)
if len(values) != 2:
raise OptionError(opt.name, "invalid value '%s'" % opt.value)
deg = degree(values[0])
if just_file:
return values[1]
return (graph.GetDegreeHistogram(deg), values[1])
elif opt.name == "degree-correlation-histogram":
return (graph.GetVertexHistogram(deg), values[1])
elif opt.name == "edge-histogram":
values = parse_values(opt.value)
if len(values) != 2:
raise OptionError(opt.name, "invalid value '%s'" % opt.value)
if just_file:
return values[1]
return (graph.GetEdgeHistogram(values[0]), values[1])
elif opt.name == "vertex-correlation-histogram":
values = parse_values(opt.value)
if len(values) != 3:
raise OptionError(opt.name, "invalid value '%s'" % opt.value)
......@@ -265,8 +275,8 @@ def parse_option(opt, just_file=False):
deg2 = degree(values[1])
if just_file:
return values[2]
return (graph.GetDegreeCorrelationHistogram(deg1,deg2), values[2])
elif opt.name == "edge-degree-correlation-histogram":
return (graph.GetVertexCorrelationHistogram(deg1,deg2), values[2])
elif opt.name == "edge-vertex-correlation-histogram":
values = parse_values(opt.value)
if len(values) != 4:
raise OptionError(opt.name, "invalid value '%s'" % opt.value)
......@@ -274,7 +284,7 @@ def parse_option(opt, just_file=False):
deg2 = degree(values[2])
if just_file:
return values[3]
return (graph.GetEdgeDegreeCorrelationHistogram(deg1,values[1],deg2), values[3])
return (graph.GetEdgeVertexCorrelationHistogram(deg1,values[1],deg2), values[3])
elif opt.name == "vertex-scalar-correlation-histogram":
values = parse_values(opt.value)
if len(values) != 3:
......@@ -283,7 +293,7 @@ def parse_option(opt, just_file=False):
if just_file:
return values[2]
return (graph.GetVertexDegreeScalarCorrelationHistogram(deg,values[1]),values[2])
elif opt.name == "average-nearest-neighbours-degree":
elif opt.name == "average-nearest-neighbours-correlation":
values = parse_values(opt.value)
if len(values) != 3:
raise OptionError(opt.name, "invalid value '%s'" % opt.value)
......@@ -291,7 +301,7 @@ def parse_option(opt, just_file=False):
deg2 = degree(values[1])
if just_file:
return values[2]
return (graph.GetAverageNearestNeighboursDegree(deg1,deg2), values[2])
return (graph.GetAverageNearestNeighboursCorrelation(deg1,deg2), values[2])
elif opt.name == "assortativity-coefficient":
values = parse_values(opt.value)
if len(values) != 2:
......@@ -300,20 +310,26 @@ def parse_option(opt, just_file=False):
if just_file:
return values[1]
return (graph.GetAssortativityCoefficient(deg), values[1])
elif opt.name == "local-clustering-coefficient":
hist = graph.GetLocalClusteringHistogram()
avg,count = 0.0,0.0
elif opt.name == "average-vertex-property" or opt.name == "average-edge-property":
values = parse_values(opt.value)
if len(values) != 2:
raise OptionError(opt.name, "invalid value '%s'" % opt.value)
if opt.name == "average-vertex-property":
deg = degree(values[0])
hist = graph.GetVertexHistogram(deg)
else:
hist = graph.GetEdgeHistogram(values[0])
avg,dev,count = 0.0,0.0,0.0
for k,v in hist.iteritems():
avg += k*v
dev += k*k*v
count += v
avg /= count
dev = math.sqrt(dev/count - avg*avg)/math.sqrt(count)
ret = "%f\t%f" % (avg, dev)
if just_file:
return opt.value
return (avg,opt.value)
elif opt.name == "local-clustering-coefficiet-histogram":
if just_file:
return opt.value
return (graph.GetLocalClusteringHistogram(), opt.value)
return values[1]
return (ret,values[1])
elif opt.name == "global-clustering-coefficient":
if just_file:
return opt.value
......
......@@ -225,15 +225,15 @@ size_t GraphInterface::GetNumberOfEdges() const
}
//==============================================================================
// get_degree_histogram
// generalized functor to obtain histogram of different types of degrees
// get_vertex_histogram
// generalized functor to obtain histogram of different types of "degrees"
//==============================================================================
template <class DegreeSelector>
struct get_degree_histogram
struct get_vertex_histogram
{
get_degree_histogram(DegreeSelector &deg): _degree(deg) {}
get_vertex_histogram(DegreeSelector& deg): _degree(deg) {}
template <class Graph, class Hist>
void operator()(const Graph &g, Hist &hist) const
void operator()(const Graph& g, Hist& hist) const
{
typename graph_traits<Graph>::vertex_iterator v, v_begin, v_end;
tie(v_begin, v_end) = vertices(g);
......@@ -243,9 +243,9 @@ struct get_degree_histogram
DegreeSelector& _degree;
};
struct choose_degree_histogram
struct choose_vertex_histogram
{
choose_degree_histogram(const GraphInterface &g, GraphInterface::deg_t deg, GraphInterface::hist_t &hist)
choose_vertex_histogram(const GraphInterface& g, GraphInterface::deg_t deg, GraphInterface::hist_t& hist)
: _g(g), _hist(hist)
{
tie(_deg, _deg_name) = get_degree_type(deg);
......@@ -256,7 +256,7 @@ struct choose_degree_histogram
if (mpl::at<degree_selector_index,DegreeSelector>::type::value == _deg)
{
DegreeSelector selector(_deg_name, _g);
check_filter(_g, bind<void>(get_degree_histogram<DegreeSelector>(selector), _1, var(_hist)),reverse_check(),directed_check());
check_filter(_g, bind<void>(get_vertex_histogram<DegreeSelector>(selector), _1, var(_hist)),reverse_check(),directed_check());
}
}
const GraphInterface &_g;
......@@ -266,14 +266,14 @@ struct choose_degree_histogram
};
//==============================================================================
// GetDegreeHistogram(deg_type)
// GetVertexHistogram(deg_type)
//==============================================================================
GraphInterface::hist_t GraphInterface::GetDegreeHistogram(GraphInterface::deg_t deg) const
GraphInterface::hist_t GraphInterface::GetVertexHistogram(GraphInterface::deg_t deg) const
{
hist_t hist;
try
{
mpl::for_each<mpl::vector<in_degreeS, out_degreeS, total_degreeS, scalarS> >(choose_degree_histogram(*this, deg, hist));
mpl::for_each<mpl::vector<in_degreeS, out_degreeS, total_degreeS, scalarS> >(choose_vertex_histogram(*this, deg, hist));
}
catch (dynamic_get_failure &e)
{
......@@ -283,6 +283,45 @@ GraphInterface::hist_t GraphInterface::GetDegreeHistogram(GraphInterface::deg_t
return hist;
}
//==============================================================================
// get_edge_histogram
// generalized functor to obtain histogram of edge properties
//==============================================================================
struct get_edge_histogram
{
get_edge_histogram(scalarS& prop): _prop(prop) {}
template <class Graph, class Hist>
void operator()(const Graph& g, Hist& hist) const
{
typename graph_traits<Graph>::edge_iterator e, e_begin, e_end;
tie(e_begin, e_end) = edges(g);
for(e = e_begin; e != e_end; ++e)
hist[_prop(*e,g)]++;
}
scalarS& _prop;
};
//==============================================================================
// GetEdgeHistogram(property)
//==============================================================================
GraphInterface::hist_t GraphInterface::GetEdgeHistogram(string property) const
{
hist_t hist;
try
{
scalarS prop(property, *this);
check_filter(*this, bind<void>(get_edge_histogram(prop), _1, var(hist)),reverse_check(),directed_check());
}
catch (dynamic_get_failure &e)
{
throw GraphException("error getting scalar property: " + string(e.what()));
}
return hist;
}
//==============================================================================
// bfs_distance_sum_visitor
// This event visitor will record and sum all the distances during a BFS.
......
......@@ -51,13 +51,6 @@ public:
SCALAR
};
enum neighbours_t
{
IN_NEIGHBOURS,
OUT_NEIGHBOURS,
ALL_NEIGHBOURS
};
// histogram types
typedef std::tr1::unordered_map<double,size_t> hist_t;
typedef std::tr1::unordered_map<std::pair<double,double>,size_t, boost::hash<std::pair<double,double> > > hist2d_t;
......@@ -71,26 +64,25 @@ public:
typedef boost::function<std::pair<size_t,size_t> (double r1, double r2)> inv_ceil_t;
typedef boost::function<double (size_t jl, size_t kl, size_t j, size_t k)> corr_t;
typedef boost::function<std::pair<size_t,size_t> (double r1, double r2, size_t j, size_t k)> inv_corr_t;
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);
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);
// basic stats
size_t GetNumberOfVertices() const;
size_t GetNumberOfEdges() const;
hist_t GetDegreeHistogram(deg_t degree) const;
hist_t GetVertexHistogram(deg_t degree) const;
hist_t GetEdgeHistogram(std::string property) const;
//correlations
hist2d_t GetCombinedDegreeHistogram() const;
hist2d_t GetDegreeCorrelationHistogram(deg_t degree1, deg_t degree2) const;
hist3d_t GetEdgeDegreeCorrelationHistogram(deg_t deg1, std::string scalar, deg_t deg2) const;
hist2d_t GetVertexDegreeScalarCorrelationHistogram(deg_t deg, std::string scalar) const;
avg_corr_t GetAverageNearestNeighboursDegree(deg_t origin_degree, deg_t neighbour_degree) const;
hist2d_t GetVertexCorrelationHistogram(deg_t degree1, deg_t degree2) const;
hist3d_t GetEdgeVertexCorrelationHistogram(deg_t deg1, std::string scalar, deg_t deg2) const;
hist2d_t GetVertexScalarCorrelationHistogram(deg_t deg, std::string scalar) const;
avg_corr_t GetAverageNearestNeighboursCorrelation(deg_t origin_degree, deg_t neighbour_degree) const;
double GetAssortativityCoefficient(deg_t deg) const;
//clustering
hist_t GetLocalClusteringHistogram() const;
void SetLocalClusteringToProperty(std::string property);
double GetGlobalClustering() const;
void SetLocalClusteringToProperty(std::string property);
double GetGlobalClustering() const;
// other
hist_t GetComponentSizeHistogram() const;
......
......@@ -213,13 +213,14 @@ BOOST_PYTHON_MODULE(libgraph_tool)
.def("GenerateCorrelatedConfigurationalModel", &GraphInterfaceWrap::GenerateCorrelatedConfigurationalModel)
.def("GetNumberOfVertices", &GraphInterfaceWrap::GetNumberOfVertices)
.def("GetNumberOfEdges", &GraphInterfaceWrap::GetNumberOfEdges)
.def("GetDegreeHistogram", &GraphInterfaceWrap::GetDegreeHistogram)
.def("GetVertexHistogram", &GraphInterfaceWrap::GetVertexHistogram)
.def("GetEdgeHistogram", &GraphInterfaceWrap::GetEdgeHistogram)
.def("GetComponentSizeHistogram", &GraphInterfaceWrap::GetComponentSizeHistogram)
.def("GetCombinedDegreeHistogram", &GraphInterfaceWrap::GetCombinedDegreeHistogram)
.def("GetDegreeCorrelationHistogram", &GraphInterfaceWrap::GetDegreeCorrelationHistogram)
.def("GetEdgeDegreeCorrelationHistogram", &GraphInterfaceWrap::GetEdgeDegreeCorrelationHistogram)
.def("GetVertexDegreeScalarCorrelationHistogram", &GraphInterfaceWrap::GetVertexDegreeScalarCorrelationHistogram)
.def("GetAverageNearestNeighboursDegree", &GraphInterfaceWrap::GetAverageNearestNeighboursDegree)
.def("GetVertexCorrelationHistogram", &GraphInterfaceWrap::GetVertexCorrelationHistogram)
.def("GetEdgeVertexCorrelationHistogram", &GraphInterfaceWrap::GetEdgeVertexCorrelationHistogram)
.def("GetVertexScalarCorrelationHistogram", &GraphInterfaceWrap::GetVertexScalarCorrelationHistogram)
.def("GetAverageNearestNeighboursCorrelation", &GraphInterfaceWrap::GetAverageNearestNeighboursCorrelation)
.def("GetAssortativityCoefficient", &GraphInterfaceWrap::GetAssortativityCoefficient)
.def("GetGlobalClustering", &GraphInterfaceWrap::GetGlobalClustering)
.def("SetLocalClusteringToProperty", &GraphInterfaceWrap::SetLocalClusteringToProperty)
......@@ -257,11 +258,6 @@ BOOST_PYTHON_MODULE(libgraph_tool)
.value("Out", GraphInterfaceWrap::OUT_DEGREE)
.value("Total", GraphInterfaceWrap::TOTAL_DEGREE);
enum_<GraphInterfaceWrap::neighbours_t>("Neighbours")
.value("In", GraphInterfaceWrap::IN_NEIGHBOURS)
.value("Out", GraphInterfaceWrap::OUT_NEIGHBOURS)
.value("All", GraphInterfaceWrap::ALL_NEIGHBOURS);
variant_from_python<string>();
variant_from_python<GraphInterfaceWrap::degree_t>();
to_python_converter<pair<double,double>, pair_to_tuple<double,double> >();
......
......@@ -90,43 +90,6 @@ pair<int,int> get_triangles(typename graph_traits<Graph>::vertex_descriptor v, c
return make_pair(triangles/2,(k*(k-1))/2);
}
//==============================================================================
// GetClusteringHistogram()
// retrieves the distribution of local clustering coefficients
//==============================================================================
struct get_clustering_histogram
{
template <class Graph, class Hist>
void operator()(const Graph &g, Hist &hist) const
{
typename get_undirected_graph<Graph>::type ug(g);
typename graph_traits<Graph>::vertex_iterator v, v_begin, v_end;
tie(v_begin, v_end) = vertices(g);
for(v = v_begin; v != v_end; ++v)
{
pair<size_t,size_t> triangles = get_triangles(*v,ug); // get from ug
double clustering = (triangles.second > 0)?double(triangles.first)/triangles.second:0.0;
hist[clustering]++;
}
}
template <class Graph>
struct get_undirected_graph
{
typedef typename mpl::if_< is_convertible<typename graph_traits<Graph>::directed_category, directed_tag>,
const UndirectedAdaptor<Graph>,
const Graph& >::type type;
};
};
GraphInterface::hist_t
GraphInterface::GetLocalClusteringHistogram() const
{
hist_t hist;
check_filter(*this, bind<void>(get_clustering_histogram(), _1, var(hist)), reverse_check(), directed_check());
return hist;
}
//==============================================================================
// GetGlobalClustering()
......@@ -205,5 +168,12 @@ void GraphInterface::SetLocalClusteringToProperty(string property)
check_filter(*this, bind<void>(set_clustering_to_property(), _1, var(clust_map)), reverse_check(), directed_check());
try
{
find_property_map(_properties, property, typeid(graph_traits<multigraph_t>::vertex_descriptor));
RemoveVertexProperty(property);
}
catch (property_not_found) {}
_properties.property(property, clust_map);
}
......@@ -100,9 +100,9 @@ struct get_correlation_histogram
//==============================================================================
template <class SecondDegreeSelectors>
struct choose_degree_correlation_histogram
struct choose_vertex_correlation_histogram
{
choose_degree_correlation_histogram(const GraphInterface &g, GraphInterface::deg_t deg1,
choose_vertex_correlation_histogram(const GraphInterface &g, GraphInterface::deg_t deg1,
GraphInterface::deg_t deg2, GraphInterface::hist2d_t &hist)
: _g(g), _hist(hist)
{
......@@ -113,7 +113,7 @@ struct choose_degree_correlation_histogram
template <class DegreeSelector1>
struct check_second_degree
{
check_second_degree(choose_degree_correlation_histogram<SecondDegreeSelectors> &parent):_parent(parent) {}
check_second_degree(choose_vertex_correlation_histogram<SecondDegreeSelectors> &parent):_parent(parent) {}
template <class DegreeSelector2>
void operator()(DegreeSelector2)
{
......@@ -125,7 +125,7 @@ struct choose_degree_correlation_histogram
reverse_check(),directed_check());
}
}
choose_degree_correlation_histogram<SecondDegreeSelectors> _parent;
choose_vertex_correlation_histogram<SecondDegreeSelectors> _parent;
};
template <class DegreeSelector>
......@@ -144,13 +144,13 @@ struct choose_degree_correlation_histogram
};
GraphInterface::hist2d_t
GraphInterface::GetDegreeCorrelationHistogram(GraphInterface::deg_t deg1, GraphInterface::deg_t deg2) const
GraphInterface::GetVertexCorrelationHistogram(GraphInterface::deg_t deg1, GraphInterface::deg_t deg2) const
{
hist2d_t hist;
typedef mpl::vector<in_degreeS, out_degreeS, total_degreeS, scalarS> degree_selectors;
try
{
mpl::for_each<degree_selectors>(choose_degree_correlation_histogram<degree_selectors>(*this, deg1, deg2, hist));
mpl::for_each<degree_selectors>(choose_vertex_correlation_histogram<degree_selectors>(*this, deg1, deg2, hist));
}
catch (dynamic_get_failure &e)
{
......@@ -195,15 +195,15 @@ struct get_edge_correlation_histogram
};
//==============================================================================
// GetEdgeDegreeCorrelationHistogram(deg1, scalar, deg2)
// GetEdgeVertexCorrelationHistogram(deg1, scalar, deg2)
// retrieves the degree-edge-degree correlation histogram
//==============================================================================
template <class SecondDegreeSelectors>
struct choose_edge_degree_correlation_histogram
struct choose_edge_vertex_correlation_histogram
{
choose_edge_degree_correlation_histogram(const GraphInterface &g, GraphInterface::deg_t deg1, scalarS& edge_scalar,
GraphInterface::deg_t deg2, GraphInterface::hist3d_t &hist)
choose_edge_vertex_correlation_histogram(const GraphInterface& g, GraphInterface::deg_t deg1, scalarS& edge_scalar,
GraphInterface::deg_t deg2, GraphInterface::hist3d_t& hist)
: _g(g), _edge_scalar(edge_scalar), _hist(hist)
{
tie(_deg1, _deg_name1) = get_degree_type(deg1);
......@@ -213,7 +213,7 @@ struct choose_edge_degree_correlation_histogram
template <class DegreeSelector1>
struct check_second_degree
{
check_second_degree(choose_edge_degree_correlation_histogram<SecondDegreeSelectors> &parent):_parent(parent) {}
check_second_degree(choose_edge_vertex_correlation_histogram<SecondDegreeSelectors> &parent):_parent(parent) {}
template <class DegreeSelector2>
void operator()(DegreeSelector2)
{
......@@ -226,7 +226,7 @@ struct choose_edge_degree_correlation_histogram
reverse_check(),directed_check());
}
}
choose_edge_degree_correlation_histogram<SecondDegreeSelectors> _parent;
choose_edge_vertex_correlation_histogram<SecondDegreeSelectors> _parent;
};
template <class DegreeSelector>
......@@ -235,9 +235,9 @@ struct choose_edge_degree_correlation_histogram
if (mpl::at<degree_selector_index,DegreeSelector>::type::value == _deg1)
mpl::for_each<SecondDegreeSelectors>(check_second_degree<DegreeSelector>(*this));
}
const GraphInterface &_g;
const GraphInterface& _g;
scalarS& _edge_scalar;
GraphInterface::hist3d_t &_hist;
GraphInterface::hist3d_t& _hist;
GraphInterface::degree_t _deg1;
string _deg_name1;
GraphInterface::degree_t _deg2;
......@@ -245,7 +245,7 @@ struct choose_edge_degree_correlation_histogram
};
GraphInterface::hist3d_t
GraphInterface::GetEdgeDegreeCorrelationHistogram(GraphInterface::deg_t deg1, string edge_scalar, GraphInterface::deg_t deg2 ) const
GraphInterface::GetEdgeVertexCorrelationHistogram(GraphInterface::deg_t deg1, string edge_scalar, GraphInterface::deg_t deg2) const
{
hist3d_t hist;
......@@ -253,9 +253,9 @@ GraphInterface::GetEdgeDegreeCorrelationHistogram(GraphInterface::deg_t deg1, st
try
{
typedef mpl::vector<in_degreeS, out_degreeS, total_degreeS, scalarS> degree_selectors;
mpl::for_each<degree_selectors>(choose_edge_degree_correlation_histogram<degree_selectors>(*this, deg1, scalar, deg2, hist));
mpl::for_each<degree_selectors>(choose_edge_vertex_correlation_histogram<degree_selectors>(*this, deg1, scalar, deg2, hist));
}
catch (dynamic_get_failure &e)
catch (dynamic_get_failure& e)
{
throw GraphException("error getting scalar property: " + string(e.what()));
}
......@@ -289,14 +289,14 @@ struct get_vertex_scalar_correlation_histogram
//==============================================================================
// GetVertexDegreeScalarCorrelationHistogram(deg, scalar)
// retrieves the degree-scalar vertex correlation histogram
// GetVertexScalarCorrelationHistogram(deg, scalar)
// retrieves the vertex-scalar correlation histogram
//==============================================================================
struct choose_vertex_degree_scalar_correlation_histogram
struct choose_vertex_scalar_correlation_histogram
{
choose_vertex_degree_scalar_correlation_histogram(const GraphInterface &g, GraphInterface::deg_t deg, scalarS& scalar,
GraphInterface::hist2d_t &hist)
choose_vertex_scalar_correlation_histogram(const GraphInterface& g, GraphInterface::deg_t deg, scalarS& scalar,
GraphInterface::hist2d_t& hist)
: _g(g), _scalar(scalar), _hist(hist)
{
tie(_deg, _deg_name) = get_degree_type(deg);
......@@ -320,7 +320,7 @@ struct choose_vertex_degree_scalar_correlation_histogram
string _deg_name;
};
GraphInterface::hist2d_t GraphInterface::GetVertexDegreeScalarCorrelationHistogram(deg_t deg, string scalar) const
GraphInterface::hist2d_t GraphInterface::GetVertexScalarCorrelationHistogram(deg_t deg, string scalar) const
{
hist2d_t hist;
......@@ -328,7 +328,7 @@ GraphInterface::hist2d_t GraphInterface::GetVertexDegreeScalarCorrelationHistogr
try
{
typedef mpl::vector<in_degreeS, out_degreeS, total_degreeS, scalarS> degree_selectors;
mpl::for_each<degree_selectors>(choose_vertex_degree_scalar_correlation_histogram(*this, deg, scalar_sel, hist));
mpl::for_each<degree_selectors>(choose_vertex_scalar_correlation_histogram(*this, deg, scalar_sel, hist));
}
catch (dynamic_get_failure &e)
{
......
......@@ -34,14 +34,14 @@ using namespace boost::lambda;
using namespace graph_tool;
//==============================================================================
// average_nearest_neighbours_degree
// return generalized average nearest neighbours degree
// average_nearest_neighbours_correlation
// return generalized average nearest neighbours correlation
//==============================================================================
template <class DegreeSelectorOrigin, class DegreeSelectorNeighbours>
struct get_average_nearest_neighbours_degree
struct get_average_nearest_neighbours_correlation
{
get_average_nearest_neighbours_degree(DegreeSelectorOrigin& origin_deg, DegreeSelectorNeighbours& neighbours_deg)
get_average_nearest_neighbours_correlation(DegreeSelectorOrigin& origin_deg, DegreeSelectorNeighbours& neighbours_deg)
: _origin_degree(origin_deg), _neighbours_degree(neighbours_deg) {}
template <class Graph, class AvgDeg>
......@@ -86,9 +86,9 @@ struct get_average_nearest_neighbours_degree
};
template <class DegreeSelectors>
struct choose_average_nearest_neighbours_degree
struct choose_average_nearest_neighbours_correlation
{
choose_average_nearest_neighbours_degree(const GraphInterface &g, GraphInterface::deg_t origin_deg, GraphInterface::deg_t neighbour_deg, GraphInterface::avg_corr_t &avg_deg)
choose_average_nearest_neighbours_correlation(const GraphInterface &g, GraphInterface::deg_t origin_deg, GraphInterface::deg_t neighbour_deg, GraphInterface::avg_corr_t &avg_deg)
: _g(g), _avg_deg(avg_deg)
{
tie(_origin_deg, _origin_deg_name) = get_degree_type(origin_deg);
......@@ -98,7 +98,7 @@ struct choose_average_nearest_neighbours_degree
template <class OriginDegreeSelector>
struct choose_neighbour_degree
{
choose_neighbour_degree(choose_average_nearest_neighbours_degree<DegreeSelectors>& parent):_parent(parent) {}
choose_neighbour_degree(choose_average_nearest_neighbours_correlation<DegreeSelectors>& parent):_parent(parent) {}
template <class DegreeSelector>
void operator()(DegreeSelector)
{
......@@ -106,12 +106,12 @@ struct choose_average_nearest_neighbours_degree
{
OriginDegreeSelector origin_deg(_parent._origin_deg_name, _parent._g);
DegreeSelector deg(_parent._neighbour_deg_name, _parent._g);
check_filter(_parent._g, bind<void>(get_average_nearest_neighbours_degree<OriginDegreeSelector,DegreeSelector>(origin_deg, deg),
check_filter(_parent._g, bind<void>(get_average_nearest_neighbours_correlation<OriginDegreeSelector,DegreeSelector>(origin_deg, deg),
_1, var(_parent._avg_deg)),
reverse_check(),directed_check());
}
}
choose_average_nearest_neighbours_degree<DegreeSelectors> &_parent;
choose_average_nearest_neighbours_correlation<DegreeSelectors> &_parent;
};