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
172e1326
Commit
172e1326
authored
May 06, 2008
by
Tiago Peixoto
Browse files
Improve edge re-indexing complexity
It was needlessly O(E^2), and now is O(E).
parent
7c957a60
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph/graph_filtering.cc
View file @
172e1326
...
...
@@ -217,11 +217,12 @@ void GraphInterface::ReIndexEdges()
for
(
tie
(
e
,
e_end
)
=
out_edges
(
*
v
,
_mg
);
e
!=
e_end
;
++
e
)
{
size_t
index
=
_edge_index
[
*
e
];
if
(
index
>=
n
um
_edges
(
_mg
)
)
if
(
index
>=
n_edges
)
continue
;
if
(
index
>=
edge_map
.
size
())
edge_map
.
resize
(
index
+
1
,
make_pair
(
edge_t
(),
false
));
edge_map
[
index
]
=
make_pair
(
*
e
,
true
);
if
(
!
edge_map
[
index
].
second
)
edge_map
[
index
]
=
make_pair
(
*
e
,
true
);
}
size_t
new_index
=
0
;
...
...
@@ -236,7 +237,7 @@ void GraphInterface::ReIndexEdges()
edge_t
old_edge
=
edge_map
[
new_index
].
first
;
if
(
edge_map
[
new_index
].
second
&&
_edge_index
[
*
e
]
!=
_edge_index
[
old_edge
])
(
_edge_index
[
*
e
]
!=
_edge_index
[
old_edge
])
)
{
// another edge exists with the same (new) index; the properties
// must be swapped
...
...
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