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
36e6fe57
Commit
36e6fe57
authored
Jul 14, 2011
by
Tiago Peixoto
Browse files
Allow for community labels to be of arbitrary types in modularity()
parent
8123d30c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/graph/community/graph_community.cc
View file @
36e6fe57
...
...
@@ -88,7 +88,7 @@ double modularity(GraphInterface& g, boost::any weight, boost::any property)
run_action
<
graph_tool
::
detail
::
never_directed
>
()
(
g
,
bind
<
void
>
(
get_modularity
(),
_1
,
_2
,
_3
,
ref
(
modularity
)),
edge_props_t
(),
vertex_
scalar_
properties
())
edge_props_t
(),
vertex_properties
())
(
weight
,
property
);
return
modularity
;
}
...
...
src/graph/community/graph_community.hh
View file @
36e6fe57
...
...
@@ -502,6 +502,7 @@ struct get_modularity
double
&
modularity
)
const
{
typedef
typename
property_traits
<
WeightMap
>::
key_type
weight_key_t
;
typedef
typename
property_traits
<
CommunityMap
>::
value_type
s_val_t
;
modularity
=
0.0
;
size_t
E
=
0
;
...
...
@@ -514,10 +515,10 @@ struct get_modularity
W
+=
get
(
weights
,
*
e
);
E
++
;
if
(
get
(
s
,
target
(
*
e
,
g
))
==
get
(
s
,
source
(
*
e
,
g
)))
modularity
+=
2
*
get
(
weights
,
weight_key_t
(
*
e
));
modularity
+=
2
*
get
(
weights
,
weight_key_t
(
*
e
));
}
unordered_map
<
s
ize
_t
,
size_t
>
Ks
;
unordered_map
<
s
_val
_t
,
size_t
>
Ks
;
typename
graph_traits
<
Graph
>::
vertex_iterator
v
,
v_end
;
for
(
tie
(
v
,
v_end
)
=
vertices
(
g
);
v
!=
v_end
;
++
v
)
...
...
Tiago Peixoto
@count0
mentioned in issue
#57 (closed)
·
Aug 06, 2014
mentioned in issue
#57 (closed)
mentioned in issue #57
Toggle commit list
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