Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Tiago Peixoto
graph-tool
Commits
859bf4aa
Commit
859bf4aa
authored
Oct 26, 2016
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
blockmodel: Add node and edge count checks
parent
407e0bff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
src/graph/inference/graph_blockmodel.hh
src/graph/inference/graph_blockmodel.hh
+33
-0
src/graph/inference/graph_blockmodel_util.hh
src/graph/inference/graph_blockmodel_util.hh
+1
-0
No files found.
src/graph/inference/graph_blockmodel.hh
View file @
859bf4aa
...
...
@@ -787,6 +787,7 @@ public:
auto
vt
=
[
&
](
auto
mrp
,
auto
mrm
,
auto
nr
)
{
assert
(
mrp
>=
0
&&
mrm
>=
0
&&
nr
>=
0
);
if
(
exact
)
return
vterm_exact
(
mrp
,
mrm
,
nr
,
_deg_corr
,
_bg
);
else
...
...
@@ -1653,6 +1654,38 @@ public:
_emat
.
sync
(
_bg
);
}
void
check_edge_counts
()
{
gt_hash_map
<
std
::
pair
<
size_t
,
size_t
>
,
size_t
>
mrs
;
for
(
auto
e
:
edges_range
(
_g
))
{
size_t
r
=
_b
[
source
(
e
,
_g
)];
size_t
s
=
_b
[
target
(
e
,
_g
)];
if
(
!
is_directed
::
apply
<
g_t
>::
type
::
value
&&
s
<
r
)
std
::
swap
(
r
,
s
);
mrs
[
std
::
make_pair
(
r
,
s
)]
+=
_eweight
[
e
];
}
for
(
auto
&
rs_m
:
mrs
)
{
auto
r
=
rs_m
.
first
.
first
;
auto
s
=
rs_m
.
first
.
second
;
auto
me
=
_emat
.
get_me
(
r
,
s
);
assert
(
me
!=
_emat
.
get_null_edge
());
assert
(
size_t
(
_mrs
[
me
])
==
rs_m
.
second
);
}
}
void
check_node_counts
()
{
vector
<
size_t
>
wr
(
num_vertices
(
_bg
));
for
(
auto
v
:
vertices_range
(
_g
))
wr
[
_b
[
v
]]
+=
_vweight
[
v
];
for
(
auto
r
:
vertices_range
(
_bg
))
assert
(
size_t
(
_wr
[
r
])
==
wr
[
r
]);
}
//private:
typedef
typename
std
::
conditional
<
is_directed
::
apply
<
g_t
>::
type
::
value
,
...
...
src/graph/inference/graph_blockmodel_util.hh
View file @
859bf4aa
...
...
@@ -1139,6 +1139,7 @@ public:
{
auto
&
rs
=
_entries
[
i
];
_mes
.
push_back
(
emat
.
get_me
(
rs
.
first
,
rs
.
second
));
assert
(
_mes
.
back
()
!=
emat
.
get_null_edge
()
||
get
<
0
>
(
_delta
[
i
])
>
0
);
}
return
_mes
;
}
...
...
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