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
edb9e873
Commit
edb9e873
authored
Aug 01, 2012
by
Tiago Peixoto
Browse files
Push is_adjacent() to graph_util.hh
parent
3721923c
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/graph/generation/graph_generation.hh
View file @
edb9e873
...
...
@@ -86,17 +86,6 @@ void print_update(size_t current, stringstream& str)
cout
<<
str
.
str
()
<<
flush
;
}
template
<
class
Graph
>
bool
is_adjacent
(
typename
graph_traits
<
Graph
>::
vertex_descriptor
u
,
typename
graph_traits
<
Graph
>::
vertex_descriptor
v
,
const
Graph
&
g
)
{
typename
graph_traits
<
Graph
>::
adjacency_iterator
a
,
a_end
;
for
(
tie
(
a
,
a_end
)
=
adjacent_vertices
(
u
,
g
);
a
!=
a_end
;
++
a
)
if
(
*
a
==
v
)
return
true
;
return
false
;
}
//
// Generation strategies
...
...
src/graph/generation/graph_rewiring.hh
View file @
edb9e873
...
...
@@ -39,21 +39,6 @@ namespace graph_tool
using
namespace
std
;
using
namespace
boost
;
// returns true if vertices u and v are adjacent. This is O(k(u)).
template
<
class
Graph
>
bool
is_adjacent
(
typename
graph_traits
<
Graph
>::
vertex_descriptor
u
,
typename
graph_traits
<
Graph
>::
vertex_descriptor
v
,
const
Graph
&
g
)
{
typename
graph_traits
<
Graph
>::
out_edge_iterator
e
,
e_end
;
for
(
tie
(
e
,
e_end
)
=
out_edges
(
u
,
g
);
e
!=
e_end
;
++
e
)
{
if
(
target
(
*
e
,
g
)
==
v
)
return
true
;
}
return
false
;
}
template
<
class
Graph
>
typename
graph_traits
<
Graph
>::
vertex_descriptor
source
(
const
pair
<
size_t
,
bool
>&
e
,
...
...
src/graph/graph_util.hh
View file @
edb9e873
...
...
@@ -107,6 +107,21 @@ struct SoftNumEdges
size_t
operator
()(
Graph
&
g
)
const
{
return
num_edges
(
g
);
}
};
// returns true if vertices u and v are adjacent. This is O(k(u)).
template
<
class
Graph
>
bool
is_adjacent
(
typename
graph_traits
<
Graph
>::
vertex_descriptor
u
,
typename
graph_traits
<
Graph
>::
vertex_descriptor
v
,
const
Graph
&
g
)
{
typename
graph_traits
<
Graph
>::
out_edge_iterator
e
,
e_end
;
for
(
tie
(
e
,
e_end
)
=
out_edges
(
u
,
g
);
e
!=
e_end
;
++
e
)
{
if
(
target
(
*
e
,
g
)
==
v
)
return
true
;
}
return
false
;
}
// computes the out-degree of a graph, ignoring self-edges
template
<
class
Graph
>
inline
size_t
...
...
Write
Preview
Supports
Markdown
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