Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
20b48710
Commit
20b48710
authored
May 03, 2016
by
Tiago Peixoto
Browse files
condensation_graph(): Fix bug with edge property sums
parent
df42fadc
Pipeline
#178
passed with stage
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/graph/generation/graph_community_network.hh
View file @
20b48710
...
...
@@ -261,10 +261,9 @@ struct get_weighted_edge_property
struct
get_edge_community_property_sum
{
template
<
class
Graph
,
class
CommunityGraph
,
class
CommunityMap
,
class
CCommunityMap
,
class
Eprop
>
class
CCommunityMap
,
class
Eprop
,
class
CEprop
>
void
operator
()(
const
Graph
&
g
,
CommunityGraph
&
cg
,
CommunityMap
s_map
,
CCommunityMap
cs_map
,
Eprop
eprop
,
Eprop
ceprop
,
bool
self_loops
)
const
CCommunityMap
cs_map
,
Eprop
eprop
,
CEprop
ceprop
)
const
{
typedef
typename
graph_traits
<
Graph
>::
vertex_descriptor
vertex_t
;
typedef
typename
graph_traits
<
CommunityGraph
>::
vertex_descriptor
...
...
@@ -292,11 +291,12 @@ struct get_edge_community_property_sum
{
cvertex_t
cs
=
comms
[
get
(
s_map
,
source
(
e
,
g
))];
cvertex_t
ct
=
comms
[
get
(
s_map
,
target
(
e
,
g
))];
if
(
cs
==
ct
&&
!
self_loops
)
continue
;
auto
&
ces
=
comm_edges
[
make_pair
(
cs
,
ct
)];
if
(
ces
.
empty
())
continue
;
ceprop
[
ces
.
back
()]
+=
eprop
[
e
];
ces
.
pop_back
();
if
(
ces
.
size
()
>
1
)
ces
.
pop_back
();
}
}
};
...
...
src/graph/generation/graph_community_network_eavg.cc
View file @
20b48710
...
...
@@ -51,15 +51,13 @@ struct get_weighted_edge_property_dispatch
void
sum_eprops
(
GraphInterface
&
gi
,
GraphInterface
&
cgi
,
boost
::
any
community_property
,
boost
::
any
condensed_community_property
,
boost
::
any
ceprop
,
boost
::
any
eprop
,
bool
self_loops
);
boost
::
any
ceprop
,
boost
::
any
eprop
);
void
community_network_eavg
(
GraphInterface
&
gi
,
GraphInterface
&
cgi
,
boost
::
any
community_property
,
boost
::
any
condensed_community_property
,
boost
::
any
eweight
,
boost
::
python
::
list
aeprops
,
bool
self_loops
)
boost
::
python
::
list
aeprops
)
{
typedef
boost
::
mpl
::
push_back
<
writable_edge_scalar_properties
,
no_eweight_map_t
>::
type
eweight_properties
;
...
...
@@ -96,15 +94,14 @@ void community_network_eavg(GraphInterface& gi, GraphInterface& cgi,
// sum weighted values
sum_eprops
(
gi
,
cgi
,
community_property
,
condensed_community_property
,
ceprop
,
temp
,
self_loops
);
condensed_community_property
,
ceprop
,
temp
);
}
else
{
// sum unweighted values
sum_eprops
(
gi
,
cgi
,
community_property
,
condensed_community_property
,
ceprop
,
eprop
,
self_loops
);
ceprop
,
eprop
);
}
}
...
...
src/graph/generation/graph_community_network_eavg_imp1.cc
View file @
20b48710
...
...
@@ -41,22 +41,18 @@ struct get_edge_sum_dispatch
template
<
class
Graph
,
class
CommunityGraph
,
class
CommunityMap
,
class
Eprop
>
void
operator
()(
const
Graph
&
g
,
CommunityGraph
&
cg
,
CommunityMap
s_map
,
boost
::
any
acs_map
,
Eprop
eprop
,
boost
::
any
aceprop
,
bool
self_loops
)
const
boost
::
any
acs_map
,
Eprop
eprop
,
boost
::
any
aceprop
)
const
{
typename
CommunityMap
::
checked_t
cs_map
=
boost
::
any_cast
<
typename
CommunityMap
::
checked_t
>
(
acs_map
);
typename
Eprop
::
checked_t
ceprop
=
boost
::
any_cast
<
typename
Eprop
::
checked_t
>
(
aceprop
);
get_edge_community_property_sum
()(
g
,
cg
,
s_map
,
cs_map
.
get_unchecked
(
num_vertices
(
cg
)),
eprop
,
ceprop
.
get_unchecked
(
num_edges
(
cg
)),
self_loops
);
get_edge_community_property_sum
()(
g
,
cg
,
s_map
,
cs_map
,
eprop
,
ceprop
);
}
};
void
sum_eprops
(
GraphInterface
&
gi
,
GraphInterface
&
cgi
,
boost
::
any
community_property
,
boost
::
any
condensed_community_property
,
boost
::
any
ceprop
,
boost
::
any
eprop
,
bool
self_loops
)
boost
::
any
ceprop
,
boost
::
any
eprop
)
{
typedef
boost
::
mpl
::
insert_range
<
writable_edge_scalar_properties
,
boost
::
mpl
::
end
<
writable_edge_scalar_properties
>::
type
,
...
...
@@ -69,8 +65,8 @@ void sum_eprops(GraphInterface& gi, GraphInterface& cgi,
(
gi
,
std
::
bind
(
get_edge_sum_dispatch
(),
std
::
placeholders
::
_1
,
std
::
ref
(
cgi
.
get_graph
()),
std
::
placeholders
::
_2
,
condensed_community_property
,
std
::
placeholders
::
_3
,
ceprop
,
self_lo
op
s
),
condensed_community_property
,
std
::
placeholders
::
_3
,
cepr
op
),
writable_vertex_properties
(),
eprops_t
())
(
community_property
,
eprop
);
}
src/graph/generation/graph_generation.cc
View file @
20b48710
...
...
@@ -111,8 +111,7 @@ void community_network_vavg(GraphInterface& gi, GraphInterface& cgi,
void
community_network_eavg
(
GraphInterface
&
gi
,
GraphInterface
&
cgi
,
boost
::
any
community_property
,
boost
::
any
condensed_community_property
,
boost
::
any
eweight
,
boost
::
python
::
list
aeprops
,
bool
self_loops
);
boost
::
any
eweight
,
boost
::
python
::
list
aeprops
);
using
namespace
boost
::
python
;
...
...
src/graph_tool/generation/__init__.py
View file @
20b48710
...
...
@@ -1804,8 +1804,7 @@ def condensation_graph(g, prop, vweight=None, eweight=None, avprops=None,
_prop
(
"v"
,
g
,
prop
),
_prop
(
"v"
,
gp
,
cprop
),
_prop
(
"e"
,
g
,
eweight
),
aep
,
self_loops
)
aep
)
return
gp
,
cprop
,
vcount
,
ecount
,
r_avp
,
r_aep
class
Sampler
(
libgraph_tool_generation
.
Sampler
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment