Skip to content
GitLab
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
a79f5dbb
Commit
a79f5dbb
authored
May 08, 2009
by
Tiago Peixoto
Browse files
Fix weighted betweeness centrality
Fix bad_any_cast bug when passing a weight property.
parent
b7188ade
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/graph/centrality/graph_betweenness.cc
View file @
a79f5dbb
...
...
@@ -78,7 +78,6 @@ struct get_betweenness
vector
<
typename
property_traits
<
VertexBetweenness
>::
value_type
>
dependency_map
(
num_vertices
(
g
));
vector
<
size_t
>
path_count_map
(
num_vertices
(
g
));
brandes_betweenness_centrality
(
g
,
vertex_betweenness
,
edge_betweenness
,
make_iterator_property_map
(
incoming_map
.
begin
(),
index_map
),
...
...
@@ -99,7 +98,7 @@ struct get_weighted_betweenness
EdgeBetweenness
edge_betweenness
,
VertexBetweenness
vertex_betweenness
,
boost
::
any
weight_map
,
bool
normalize
,
size_t
n
)
const
size_t
n
,
size_t
max_eindex
)
const
{
vector
<
vector
<
typename
graph_traits
<
Graph
>::
edge_descriptor
>
>
incoming_map
(
num_vertices
(
g
));
...
...
@@ -109,13 +108,16 @@ struct get_weighted_betweenness
dependency_map
(
num_vertices
(
g
));
vector
<
size_t
>
path_count_map
(
num_vertices
(
g
));
typename
EdgeBetweenness
::
checked_t
weight
=
any_cast
<
typename
EdgeBetweenness
::
checked_t
>
(
weight_map
);
brandes_betweenness_centrality
(
g
,
vertex_betweenness
,
edge_betweenness
,
make_iterator_property_map
(
incoming_map
.
begin
(),
vertex_index
),
make_iterator_property_map
(
distance_map
.
begin
(),
vertex_index
),
make_iterator_property_map
(
dependency_map
.
begin
(),
vertex_index
),
make_iterator_property_map
(
path_count_map
.
begin
(),
vertex_index
),
vertex_index
,
any_cast
<
EdgeBetweenness
>
(
weight_map
));
vertex_index
,
weight
.
get_unchecked
(
max_eindex
+
1
));
if
(
normalize
)
normalize_betweenness
(
g
,
edge_betweenness
,
vertex_betweenness
,
n
);
}
...
...
@@ -127,10 +129,12 @@ void betweenness(GraphInterface& g, boost::any weight,
bool
normalize
)
{
if
(
!
belongs
<
edge_floating_properties
>
()(
edge_betweenness
))
throw
GraphException
(
"edge property must be of floating point value type"
);
throw
GraphException
(
"edge property must be of floating point value"
" type"
);
if
(
!
belongs
<
vertex_floating_properties
>
()(
vertex_betweenness
))
throw
GraphException
(
"vertex property must be of floating point value type"
);
throw
GraphException
(
"vertex property must be of floating point value"
" type"
);
if
(
!
weight
.
empty
())
{
...
...
@@ -138,7 +142,7 @@ void betweenness(GraphInterface& g, boost::any weight,
(
g
,
lambda
::
bind
<
void
>
(
get_weighted_betweenness
(),
lambda
::
_1
,
g
.
GetVertexIndex
(),
lambda
::
_2
,
lambda
::
_3
,
weight
,
normalize
,
g
.
GetNumberOfVertices
()),
g
.
GetNumberOfVertices
()
,
g
.
GetMaxEdgeIndex
()
),
edge_floating_properties
(),
vertex_floating_properties
())
(
edge_betweenness
,
vertex_betweenness
);
...
...
src/graph/graph.hh
View file @
a79f5dbb
...
...
@@ -153,6 +153,8 @@ public:
multigraph_t
&
GetGraph
()
{
return
_mg
;}
vertex_index_map_t
GetVertexIndex
()
{
return
_vertex_index
;}
edge_index_map_t
GetEdgeIndex
()
{
return
_edge_index
;}
size_t
GetMaxEdgeIndex
(){
return
_max_edge_index
;}
graph_index_map_t
GetGraphIndex
()
{
return
graph_index_map_t
(
0
);}
void
AddEdgeIndex
(
const
edge_t
&
e
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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