Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
deaf47f1
Commit
deaf47f1
authored
Apr 28, 2012
by
Davis King
Browse files
Added the graph_has_symmetric_edges() routine.
parent
4d2d6dda
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
dlib/graph_utils/graph_utils.h
dlib/graph_utils/graph_utils.h
+31
-0
dlib/graph_utils/graph_utils_abstract.h
dlib/graph_utils/graph_utils_abstract.h
+20
-0
No files found.
dlib/graph_utils/graph_utils.h
View file @
deaf47f1
...
@@ -410,6 +410,37 @@ namespace dlib
...
@@ -410,6 +410,37 @@ namespace dlib
return
(
visited
.
size
()
==
g
.
number_of_nodes
());
return
(
visited
.
size
()
==
g
.
number_of_nodes
());
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
bool
graph_has_symmetric_edges
(
const
T
&
graph
)
{
for
(
unsigned
long
i
=
0
;
i
<
graph
.
number_of_nodes
();
++
i
)
{
for
(
unsigned
long
j
=
0
;
j
<
graph
.
node
(
i
).
number_of_children
();
++
j
)
{
const
unsigned
long
jj
=
graph
.
node
(
i
).
child
(
j
).
index
();
// make sure every edge from a parent to a child has an edge linking back
if
(
graph
.
has_edge
(
jj
,
i
)
==
false
)
return
false
;
}
for
(
unsigned
long
j
=
0
;
j
<
graph
.
node
(
i
).
number_of_parents
();
++
j
)
{
const
unsigned
long
jj
=
graph
.
node
(
i
).
parent
(
j
).
index
();
// make sure every edge from a child to a parent has an edge linking back
if
(
graph
.
has_edge
(
i
,
jj
)
==
false
)
return
false
;
}
}
return
true
;
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
...
...
dlib/graph_utils/graph_utils_abstract.h
View file @
deaf47f1
...
@@ -81,6 +81,26 @@ namespace dlib
...
@@ -81,6 +81,26 @@ namespace dlib
parent node g.node(parent_idx) to child node g.node(child_idx).
parent node g.node(parent_idx) to child node g.node(child_idx).
!*/
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
bool
graph_has_symmetric_edges
(
const
T
&
graph
);
/*!
requires
- T is an implementation of directed_graph/directed_graph_kernel_abstract.h
ensures
- if (All nodes have either 0 edges between them or 2 edges between them.
That is, if there is an edge pointing from node A to node B then there is
also an edge from B to A) then
- returns true
- else
- returns false
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
...
...
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