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
137eb9fd
Commit
137eb9fd
authored
Jul 19, 2013
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix clear_vertex() and remove_edge(s, t, g) in adj_list<>
parent
44739a41
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
33 deletions
+77
-33
src/graph/graph_adjacency.hh
src/graph/graph_adjacency.hh
+77
-33
No files found.
src/graph/graph_adjacency.hh
View file @
137eb9fd
...
...
@@ -548,6 +548,8 @@ inline Vertex add_vertex(adj_list<Vertex>& g)
template
<
class
Vertex
>
inline
void
clear_vertex
(
Vertex
v
,
adj_list
<
Vertex
>&
g
)
{
if
(
!
g
.
_keep_epos
)
{
typename
adj_list
<
Vertex
>::
edge_list_t
&
oes
=
g
.
_out_edges
[
v
];
for
(
size_t
i
=
0
;
i
<
oes
.
size
();
++
i
)
{
...
...
@@ -581,6 +583,41 @@ inline void clear_vertex(Vertex v, adj_list<Vertex>& g)
}
g
.
_n_edges
-=
ies
.
size
();
ies
.
clear
();
}
else
{
typename
adj_list
<
Vertex
>::
edge_list_t
&
oes
=
g
.
_out_edges
[
v
];
for
(
size_t
i
=
0
;
i
<
oes
.
size
();
++
i
)
{
Vertex
t
=
oes
[
i
].
first
;
size_t
idx
=
oes
[
i
].
second
;
typename
adj_list
<
Vertex
>::
edge_list_t
&
ies
=
g
.
_in_edges
[
t
];
const
std
::
pair
<
int32_t
,
int32_t
>&
pos
=
g
.
_epos
[
idx
];
g
.
_epos
[
ies
.
back
().
second
].
second
=
pos
.
second
;
ies
[
pos
.
second
]
=
ies
.
back
();
ies
.
pop_back
();
g
.
_free_indexes
.
push_back
(
idx
);
}
g
.
_n_edges
-=
oes
.
size
();
oes
.
clear
();
typename
adj_list
<
Vertex
>::
edge_list_t
&
ies
=
g
.
_in_edges
[
v
];
for
(
size_t
i
=
0
;
i
<
ies
.
size
();
++
i
)
{
Vertex
s
=
ies
[
i
].
first
;
size_t
idx
=
ies
[
i
].
second
;
typename
adj_list
<
Vertex
>::
edge_list_t
&
oes
=
g
.
_out_edges
[
s
];
const
std
::
pair
<
int32_t
,
int32_t
>&
pos
=
g
.
_epos
[
idx
];
g
.
_epos
[
oes
.
back
().
second
].
first
=
pos
.
first
;
oes
[
pos
.
first
]
=
oes
.
back
();
oes
.
pop_back
();
g
.
_free_indexes
.
push_back
(
idx
);
}
g
.
_n_edges
-=
ies
.
size
();
ies
.
clear
();
}
}
// O(V + E)
...
...
@@ -689,6 +726,8 @@ template <class Vertex>
inline
void
remove_edge
(
Vertex
s
,
Vertex
t
,
adj_list
<
Vertex
>&
g
)
{
if
(
!
g
.
_keep_epos
)
{
typename
adj_list
<
Vertex
>::
edge_list_t
&
oes
=
g
.
_out_edges
[
s
];
for
(
size_t
i
=
0
;
i
<
oes
.
size
();
++
i
)
{
...
...
@@ -706,6 +745,11 @@ inline void remove_edge(Vertex s, Vertex t,
if
(
s
==
ies
[
i
].
first
)
ies
.
erase
(
ies
.
begin
()
+
i
);
}
}
else
{
remove_edge
(
edge
(
s
,
t
,
g
).
first
,
g
);
}
}
template
<
class
Vertex
>
...
...
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