Commit 98c329f7 authored by Tiago de Paula Peixoto's avatar Tiago de Paula Peixoto

Merge commit 'tags/release-1.1.2' into release-1.1

parents c7ab73fa e167422c
This diff is collapsed.
dnl Process this file with autoconf to produce a configure script.
AC_INIT(graph-tool, 1.1.1)
AC_INIT(graph-tool, 1.1.2)
AC_CONFIG_SRCDIR(src/graph-tool)
AM_INIT_AUTOMAKE
AM_PROG_CC_C_O
......@@ -13,6 +13,7 @@ AC_PROG_CXX
AC_LANG_CPLUSPLUS
AC_PROG_CC_STDC
AC_HEADER_STDC
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_PROG_INSTALL
......@@ -31,7 +32,7 @@ AC_ARG_ENABLE([debug], [AC_HELP_STRING([--enable-debug@<:@=full@:>@],
dnl set template depth and hidden visibility
[CXXFLAGS="$CXXFLAGS -ftemplate-depth-150 -fvisibility=hidden -fvisibility-inlines-hidden "]
[CXXFLAGS="$CXXFLAGS -ftemplate-depth-150 "]
AC_MSG_CHECKING(whether to enable function inlining...)
......@@ -62,42 +63,16 @@ AC_ARG_ENABLE([optimization], [AC_HELP_STRING([--disable-optimization],
[CXXFLAGS=" $CXXFLAGS -O99 "]
)
AC_MSG_CHECKING(whether to enable extra optimizations...)
AC_ARG_ENABLE([extra-optimizations], [AC_HELP_STRING([--enable-extra-optimizations],
[enable extra, possibly dangerous, optimizations [default=no]])],
if test $enableval = yes; then
[AC_MSG_RESULT(yes)]
[AC_DEFINE([EXTRA_OPTIMIZATIONS], 1, [enable extra optimizations])]
[CXXFLAGS="$CXXFLAGS -fmodulo-sched -fgcse-sm -fgcse-las "]
[CXXFLAGS="$CXXFLAGS -fgcse-after-reload -floop-optimize2 "]
[CXXFLAGS="$CXXFLAGS -ftree-loop-linear -ftree-loop-im "]
[CXXFLAGS="$CXXFLAGS -ftree-loop-ivcanon -fivopts -ftree-vectorize "]
[CXXFLAGS="$CXXFLAGS -ftracer -funroll-loops "]
[CXXFLAGS="$CXXFLAGS -fvariable-expansion-in-unroller -fpeel-loops"]
dnl [CXXFLAGS="$CXXFLAGS -freorder-blocks-and-partition "]
[CXXFLAGS="$CXXFLAGS -fmove-loop-invariants -funswitch-loops "]
[CXXFLAGS="$CXXFLAGS -fforce-addr -freschedule-modulo-scheduled-loops "]
else
[AC_MSG_RESULT(no)]
fi
AC_MSG_CHECKING(whether to enable hidden visibility...)
AC_ARG_ENABLE([visibility], [AC_HELP_STRING([--disable-visibility],
[disable hidden visibility [default=yes] ])],
[AC_MSG_RESULT(no)]
,
[AC_MSG_RESULT(no)] )
[AC_MSG_RESULT(yes)]
[CXXFLAGS=" $CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden "]
)
AC_MSG_CHECKING(whether to link statically...)
AC_ARG_ENABLE([static-linkage], [AC_HELP_STRING([--enable-static-linkage],
[enable static linkage [default=no]])],
if test $enableval = yes; then
[AC_MSG_RESULT(yes)]
STATIC=yes
else
STATIC=no
[AC_MSG_RESULT(no)]
fi
,
STATIC=no
[AC_MSG_RESULT(no)] )
AM_CONDITIONAL(STATIC, test $STATIC = yes)
AC_MSG_CHECKING(whether to enable graph python filtering...)
AC_ARG_ENABLE([python-filtering], [AC_HELP_STRING([--enable-python-filtering],
......@@ -130,6 +105,25 @@ AC_ARG_ENABLE([range-filtering], [AC_HELP_STRING([--disable-range-filtering],
NO_RANGE_FILTERING=no
)
AC_MSG_CHECKING(whether to enable parallel algorithms with openmp...)
AC_ARG_ENABLE([openmp], [AC_HELP_STRING([--enable-openmp],
[enable openmp [default=no] ])],
if test $enableval = yes; then
[AC_MSG_RESULT(yes)]
[AC_DEFINE([USING_OPENMP], 1, [using openmp])]
USING_OPENMP=yes
[CXXFLAGS="$CXXFLAGS -fopenmp"]
[OPENMP_LDFLAGS=" -lgomp "]
fi
,
[AC_MSG_RESULT(no)]
[AC_DEFINE([USING_OPENMP], 0, [using openmp])]
USING_OPENMP=no
[CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas"]
[OPENMP_LDFLAGS=""]
)
AC_SUBST(OPENMP_LDFLAGS)
dnl Checks for programs.
......
......@@ -43,8 +43,8 @@ EXIT_FAILURE=1
PROGRAM=ltmain.sh
PACKAGE=libtool
VERSION=1.5.23b
TIMESTAMP=" (1.1220.2.437 2007/02/17 09:08:45)"
VERSION=1.5.24
TIMESTAMP=" (1.1220.2.456 2007/06/24 02:25:32)"
# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
......@@ -1705,9 +1705,9 @@ EOF
-no-install)
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
# The PATH hackery in wrapper scripts is required on Windows
# in order for the loader to find any dlls it needs.
# and Darwin in order for the loader to find any dlls it needs.
$echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
$echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
fast_install=no
......@@ -3253,9 +3253,10 @@ EOF
age="0"
;;
irix|nonstopux)
current=`expr $number_major + $number_minor - 1`
current=`expr $number_major + $number_minor`
age="$number_minor"
revision="$number_minor"
lt_irix_increment=no
;;
esac
;;
......@@ -3314,7 +3315,8 @@ EOF
versuffix="$major.$age.$revision"
# Darwin ld doesn't like 0 for these options...
minor_current=`expr $current + 1`
verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
;;
freebsd-aout)
......@@ -3328,8 +3330,11 @@ EOF
;;
irix | nonstopux)
major=`expr $current - $age + 1`
if test "X$lt_irix_increment" = "Xno"; then
major=`expr $current - $age`
else
major=`expr $current - $age + 1`
fi
case $version_type in
nonstopux) verstring_prefix=nonstopux ;;
*) verstring_prefix=sgi ;;
......@@ -6544,8 +6549,6 @@ relink_command=\"$relink_command\""
do
eval "if test \"\${save_$lt_var+set}\" = set; then
$lt_var=\$save_$lt_var; export $lt_var
else
$lt_unset $lt_var
fi"
done
......
This diff is collapsed.
......@@ -155,7 +155,7 @@ class mutate_graph_impl : public mutate_graph
public:
put_property(const std::string& name, dynamic_properties& dp, const Key& key,
const std::string& value, const std::string& value_type,
char** type_names, bool& type_found)
const char** type_names, bool& type_found)
: m_name(name), m_dp(dp), m_key(key), m_value(value),
m_value_type(value_type), m_type_names(type_names),
m_type_found(type_found) {}
......@@ -174,7 +174,7 @@ class mutate_graph_impl : public mutate_graph
const Key& m_key;
const std::string& m_value;
const std::string& m_value_type;
char** m_type_names;
const char** m_type_names;
bool& m_type_found;
};
......@@ -182,11 +182,11 @@ protected:
MutableGraph& m_g;
dynamic_properties& m_dp;
typedef mpl::vector<bool, int, long, float, double, std::string> value_types;
static char* m_type_names[];
static const char* m_type_names[];
};
template<typename MutableGraph>
char* mutate_graph_impl<MutableGraph>::m_type_names[] = {"boolean", "int", "long", "float", "double", "string"};
const char* mutate_graph_impl<MutableGraph>::m_type_names[] = {"boolean", "int", "long", "float", "double", "string"};
void
read_graphml(std::istream& in, mutate_graph& g);
......@@ -203,7 +203,7 @@ template <typename Types>
class get_type_name
{
public:
get_type_name(const std::type_info& type, char** type_names, std::string& type_name)
get_type_name(const std::type_info& type, const char** type_names, std::string& type_name)
: m_type(type), m_type_names(type_names), m_type_name(type_name) {}
template <typename Type>
void operator()(Type)
......@@ -213,7 +213,7 @@ public:
}
private:
const std::type_info &m_type;
char** m_type_names;
const char** m_type_names;
std::string &m_type_name;
};
......@@ -235,7 +235,7 @@ write_graphml(std::ostream& out, const Graph& g, VertexIndexMap vertex_index,
<< "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd\">\n";
typedef mpl::vector<bool, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double, long double, std::string> value_types;
char* type_names[] = {"boolean", "int", "int", "int", "int", "long", "long", "long", "long", "float", "double", "double", "string"};
const char* type_names[] = {"boolean", "int", "int", "int", "int", "long", "long", "long", "long", "float", "double", "double", "string"};
std::map<std::string, std::string> graph_key_ids;
std::map<std::string, std::string> vertex_key_ids;
std::map<std::string, std::string> edge_key_ids;
......
#! /usr/bin/env python
# (C) 2006 by Tiago de Paula Peixoto <tiago@forked.de>
# graph-tool -- a general graph modification and manipulation thingy
#
# Copyright (C) 2007 Tiago de Paula Peixoto <tiago@forked.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
......@@ -111,6 +113,9 @@ statistics.add_option("--average-edge-property", action="callback", callback=pus
statistics.add_option("--reciprocity", action="callback", callback=push_option, type="string", metavar="FILE", help="get the edge reciprocity")
statistics.add_option("--minimum-spanning-tree", action="callback", callback=push_option, type="string", metavar="[WEIGHT|]PROPERTY", help="mark the minimum spanning tree edges in PROPERTY")
statistics.add_option("--line-graph", action="callback", callback=push_option, type="string", metavar="FILE[|FORMAT]", help="save the corresponding line graph to FILE")
statistics.add_option("--betweenness-centrality", action="callback", callback=push_option, type="string", metavar="VERTEX_BETWEENESS[|EDGE_BETWEENESS[|WEIGHT]]", help="calculate and store the vertex and/or edge betweenness centrality")
statistics.add_option("--central-point-dominance", action="callback", callback=push_option, type="string", metavar="VERTEX_BETWEENESS|FILE", help="calculate central point dominance, given the VERTEX_BETWEENESS vertex property")
correlations = parser.add_option_group("Correlations")
correlations.add_option("--average-combined-vertex-correlation", action="callback", callback=push_option, type="string", metavar="DEGREE1|DEGREE2|FILE", help="get the average of DEGREE2 in function of DEGREE1. Scalar properties are also accepted as DEGREE1 or DEGREE2")
......@@ -121,9 +126,9 @@ correlations.add_option("--assortativity-coefficient", action="callback", callba
correlations.add_option("--scalar-assortativity-coefficient", action="callback", callback=push_option, type="string", metavar="DEGREE|FILE", help="get the scalar assortativity coefficient. Scalar properties are also accepted in place of DEGREE")
clustering = parser.add_option_group("Clustering")
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("--local-clustering-coefficient", 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")
clustering.add_option("--set-extended-clustering-to-property", action="callback", callback=push_option, type="string", metavar="PREFIX|MAX", help="set the extended clustering coefficients c1 to cMAX to vertex properties PREFIX1 to PREFIXMAX")
clustering.add_option("--extended-clustering-coefficient", action="callback", callback=push_option, type="string", metavar="PREFIX|MAX", help="set the extended clustering coefficients c1 to cMAX to vertex properties PREFIX1 to PREFIXMAX")
layout = parser.add_option_group("Layout")
layout.add_option("--compute-spring-block-layout", action="callback", callback=push_option, type="string", metavar="ITERATIONS[|SEED]", help="compute the spring block layout")
......@@ -503,6 +508,29 @@ def parse_option(opt, just_file=False):
else:
format = ""
graph.GetLineGraph(values[0], format)
elif opt.name == "betweenness-centrality":
values = parse_values(opt.value)
if len(values) < 1 or len(values) > 3:
raise OptionError(opt.name, "invalid value '%s'" % opt.value)
if just_file:
return None
vertex_centrality = values[0]
if len(values) > 1:
edge_centrality = values[1]
else:
edge_centrality = ""
if len(values) > 2:
weight = values[2]
else:
weight = ""
graph.GetBetweenness(weight, vertex_centrality, edge_centrality)
elif opt.name == "central-point-dominance":
values = parse_values(opt.value)
if len(values) != 2:
raise OptionError(opt.name, "invalid value '%s'" % opt.value)
if just_file:
return None
return (graph.GetCentralPointDominance(values[0]), values[1])
elif opt.name == "vertex-correlation-histogram":
values = parse_values(opt.value)
if len(values) < 3 or len(values) > 4:
......@@ -581,11 +609,11 @@ def parse_option(opt, just_file=False):
(avg, dev) = graph.GetGlobalClustering()
ret = "%f\t%f" % (avg, dev)
return (ret, opt.value)
elif opt.name == "set-local-clustering-to-property":
elif opt.name == "local-clustering-coefficient":
if just_file:
return None
graph.SetLocalClusteringToProperty(opt.value)
elif opt.name == "set-extended-clustering-to-property":
elif opt.name == "extended-clustering-coefficient":
if just_file:
return None
values = parse_values(opt.value)
......
......@@ -40,15 +40,18 @@ libgraph_tool_la_SOURCES = \
graph_community.cc\
graph_community_network.cc\
graph_line_graph.cc\
graph_betweenness.cc\
graph_io.cc\
graph_bind.cc\
graphml.cpp\
histogram.hh\
shared_map.hh\
read_graphviz_spirit.cpp
libgraph_tool_la_LIBADD = \
$(PYTHON_LDFLAGS) \
$(BOOST_LDFLAGS) \
$(OPENMP_LDFLAGS) \
-lboost_python \
-lboost_iostreams \
-lexpat
......
// graph-tool -- a general graph modification and manipulation thingy
//
// Copyright (C) 2006 Tiago de Paula Peixoto <tiago@forked.de>
// Copyright (C) 2007 Tiago de Paula Peixoto <tiago@forked.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
......@@ -39,6 +39,7 @@
#include "graph_filtering.hh"
#include "graph_selectors.hh"
#include "graph_properties.hh"
#include "shared_map.hh"
using namespace std;
using namespace boost;
......@@ -232,10 +233,17 @@ struct get_vertex_histogram
template <class Graph, class Hist>
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);
for(v = v_begin; v != v_end; ++v)
hist[_degree(*v,g)]++;
SharedMap<Hist> s_hist(hist);
int i, N = num_vertices(g);
#pragma omp parallel for default(shared) private(i) firstprivate(s_hist) schedule(dynamic)
for (i = 0; i < N; ++i)
{
typename graph_traits<Graph>::vertex_descriptor v = vertex(i, g);
if (v == graph_traits<Graph>::null_vertex())
continue;
s_hist[_degree(v,g)]++;
}
s_hist.Gather();
}
DegreeSelector& _degree;
};
......@@ -290,10 +298,25 @@ struct get_edge_histogram
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)]++;
SharedMap<Hist> s_hist(hist);
int i, N = num_vertices(g);
#pragma omp parallel for default(shared) private(i) firstprivate(s_hist) schedule(dynamic)
for (i = 0; i < N; ++i)
{
typename graph_traits<Graph>::vertex_descriptor v = vertex(i, g);
if (v == graph_traits<Graph>::null_vertex())
continue;
typename graph_traits<Graph>::out_edge_iterator e, e_begin, e_end;
tie(e_begin,e_end) = out_edges(v,g);
for(e = e_begin; e != e_end; ++e)
if(is_convertible<typename graph_traits<Graph>::directed_category, undirected_tag>::value)
s_hist[_prop(*e,g)] += 0.5;
else
s_hist[_prop(*e,g)]++;
}
s_hist.Gather();
}
scalarS& _prop;
};
......@@ -370,18 +393,23 @@ struct label_parallel_edges
template <class Graph, class EdgeIndexMap, class ParallelMap>
void operator()(const Graph& g, EdgeIndexMap edge_index, ParallelMap parallel) const
{
typename graph_traits<Graph>::vertex_iterator v, v_end;
for (tie(v, v_end) = vertices(g); v != v_end; ++v)
int i, N = num_vertices(g);
#pragma omp parallel for default(shared) private(i) schedule(dynamic)
for (i = 0; i < N; ++i)
{
typename graph_traits<Graph>::vertex_descriptor v = vertex(i, g);
if (v == graph_traits<Graph>::null_vertex())
continue;
tr1::unordered_set<typename graph_traits<Graph>::edge_descriptor,DescriptorHash<EdgeIndexMap> > p_edges(0, DescriptorHash<EdgeIndexMap>(edge_index));
typename graph_traits<Graph>::out_edge_iterator e1, e2, e_end;
for (tie(e1, e_end) = out_edges(*v, g); e1 != e_end; ++e1)
for (tie(e1, e_end) = out_edges(v, g); e1 != e_end; ++e1)
{
if (p_edges.find(*e1) != p_edges.end())
continue;
size_t n = 0;
put(parallel, *e1, n);
for (tie(e2, e_end) = out_edges(*v, g); e2 != e_end; ++e2)
for (tie(e2, e_end) = out_edges(v, g); e2 != e_end; ++e2)
if (*e2 != *e1 && target(*e1, g) == target(*e2, g))
{
put(parallel, *e2, ++n);
......
// graph-tool -- a general graph modification and manipulation thingy
//
// Copyright (C) 2006 Tiago de Paula Peixoto <tiago@forked.de>
// Copyright (C) 2007 Tiago de Paula Peixoto <tiago@forked.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
......@@ -97,7 +97,9 @@ public:
double GetReciprocity() const;
void GetMinimumSpanningTree(std::string weight, std::string property);
void GetLineGraph(std::string out_file, std::string format);
void GetBetweenness(std::string weight, std::string edge_betweenness, std::string vertex_betweenness);
double GetCentralPointDominance(std::string vertex_betweenness);
// community structure
enum comm_corr_t
{
......
// graph-tool -- a general graph modification and manipulation thingy
//
// Copyright (C) 2006 Tiago de Paula Peixoto <tiago@forked.de>
// Copyright (C) 2007 Tiago de Paula Peixoto <tiago@forked.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
......@@ -357,6 +357,9 @@ struct graph_traits< UndirectedAdaptor<Graph> > {
static vertex_descriptor null_vertex() {return graph_traits<Graph>::null_vertex();}
};
template <class Graph>
struct graph_traits< const UndirectedAdaptor<Graph> >: public graph_traits< UndirectedAdaptor<Graph> > {};
//==============================================================================
// Nonmember functions
// these provide manipulation to the graph
......
// graph-tool -- a general graph modification and manipulation thingy
//
// Copyright (C) 2006 Tiago de Paula Peixoto <tiago@forked.de>
// Copyright (C) 2007 Tiago de Paula Peixoto <tiago@forked.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
......@@ -27,6 +27,7 @@
#include "graph_filtering.hh"
#include "graph_selectors.hh"
#include "graph_properties.hh"
#include "shared_map.hh"
using namespace std;
using namespace boost;
......@@ -42,35 +43,39 @@ struct get_assortativity_coefficient
{
get_assortativity_coefficient(DegreeSelector& deg): _deg(deg) {}
template <class Graph>
void operator()(const Graph& g, double& r, double& r_err) const
{
size_t n_edges = 0;
int e_kk = 0;
tr1::unordered_map<double,int> a, b;
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)
SharedMap<tr1::unordered_map<double,int> > sa(a), sb(b);
int i, N = num_vertices(g);
#pragma omp parallel for default(shared) private(i) firstprivate(sa,sb) schedule(dynamic) reduction(+:e_kk, n_edges)
for (i = 0; i < N; ++i)
{
double k1, k2;
k1 = _deg(source(*e,g),g);
k2 = _deg(target(*e,g),g);
a[k1]++;
b[k2]++;
if (k1 == k2)
e_kk++;
n_edges++;
if(is_convertible<typename graph_traits<Graph>::directed_category, undirected_tag>::value)
typename graph_traits<Graph>::vertex_descriptor v = vertex(i, g);
if (v == graph_traits<Graph>::null_vertex())
continue;
double k1 = _deg(v, g);
typename graph_traits<Graph>::out_edge_iterator e, e_end;
for (tie(e,e_end) = out_edges(v, g); e != e_end; ++e)
{
a[k2]++;
a[k1]++;
double k2 = _deg(target(*e, g), g);
sa[k1]++;
sb[k2]++;
if (k1 == k2)
e_kk++;
n_edges++;
}
}
sa.Gather();
sb.Gather();
double t1=double(e_kk)/n_edges, t2=0.0;
for (typeof(a.begin()) iter = a.begin(); iter != a.end(); ++iter)
......@@ -81,24 +86,29 @@ struct get_assortativity_coefficient
r = (t1 - t2)/(1.0 - t2);
// "jackknife" variance
r_err = 0.0;
for (e = e_begin; e != e_end; ++e)
double err = 0.0;
#pragma omp parallel for default(shared) private(i) schedule(dynamic) reduction(+:err)
for (i = 0; i < N; ++i)
{
double k1, k2;
k1 = _deg(source(*e,g),g);
k2 = _deg(target(*e,g),g);
int one = 1;
if(is_convertible<typename graph_traits<Graph>::directed_category, undirected_tag>::value)
one = 2; // nice! :-)
double tl2 = (t2*(n_edges*n_edges) - b[k1] - a[k2])/((n_edges-one)*(n_edges-one));
double tl1 = t1*n_edges;
if (k1==k2)
tl1 -= one;
tl1 /= n_edges - one;
double rl = (tl1 - tl2)/(1.0 - tl2);
r_err += (r-rl)*(r-rl);
typename graph_traits<Graph>::vertex_descriptor v = vertex(i, g);
if (v == graph_traits<Graph>::null_vertex())
continue;
double k1 = _deg(v, g);
typename graph_traits<Graph>::out_edge_iterator e, e_end;
for (tie(e,e_end) = out_edges(v, g); e != e_end; ++e)
{
double k2 = _deg(target(*e,g),g);
double tl2 = (t2*(n_edges*n_edges) - b[k1] - a[k2])/((n_edges-1)*(n_edges-1));
double tl1 = t1*n_edges;
if (k1 == k2)
tl1 -= 1;
tl1 /= n_edges - 1;
double rl = (tl1 - tl2)/(1.0 - tl2);
err += (r-rl)*(r-rl);
}
}
r_err = sqrt(r_err);
r_err = sqrt(err);
}
DegreeSelector& _deg;
......@@ -166,33 +176,38 @@ struct get_scalar_assortativity_coefficient
size_t n_edges = 0;
double e_xy = 0.0;
tr1::unordered_map<double,int> a, b;
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)
SharedMap<tr1::unordered_map<double,int> > sa(a), sb(b);
int i, N = num_vertices(g);
#pragma omp parallel for default(shared) private(i) firstprivate(sa,sb) schedule(dynamic) reduction(+:e_xy, n_edges)
for (i = 0; i < N; ++i)
{
double k1, k2;
k1 = _deg(source(*e,g),g);
k2 = _deg(target(*e,g),g);
a[k1]++;
b[k2]++;
e_xy += k1*k2;
n_edges++;
if(is_convertible<typename graph_traits<Graph>::directed_category, undirected_tag>::value)
typename graph_traits<Graph>::vertex_descriptor v = vertex(i, g);
if (v == graph_traits<Graph>::null_vertex())
continue;
double k1 = _deg(v, g);
typename graph_traits<Graph>::out_edge_iterator e, e_end;
for (tie(e,e_end) = out_edges(v, g); e != e_end; ++e)
{
a[k2]++;
b[k1]++;
double k2 = _deg(target(*e,g),g);
sa[k1]++;