[BGL] working file_dependencies.cpp
Hello,
I've already though some time that something does not work as expected
using the way the various file_dependencies.cpp examples have done for
calculating what files could be compiled in parallel. Because I've now
got to a point where I really need something working, I've just done it
myself. ;)
My solution is pretty simple, and it basically works like it is
described in the documentation for the example, walk through the tree
and calculate the maximum distance. To achieve that, I'm just using the
result from topological_sort and calculating the maximum through a walk
through the in_edges of the vertices.
Because a diff is almost as large as the resulting example, I've just
attached the modified example. It might not look as nice as the original
example, but it works as expected. ;)
Kind regards,
Alexander Holler
//=======================================================================
// Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================
// Some small modifications are done by Alexander Holler
/*
Paul Moore's request:
As an example of a practical problem which is not restricted to graph
"experts", consider file dependencies. It's basically graph construction,
plus topological sort, but it might make a nice "tutorial" example. Build a
dependency graph of files, then use the algorithms to do things like
1. Produce a full recompilation order (topological sort, by modified date)
2. Produce a "parallel" recompilation order (same as above, but group files
which can be built in parallel)
3. Change analysis (if I change file x, which others need recompiling)
4. Dependency changes (if I add a dependency between file x and file y, what
are the effects)
*/
#include
On Tue, 2006-11-21 at 04:23 +0100, Alexander Holler wrote:
Hello,
I've already though some time that something does not work as expected using the way the various file_dependencies.cpp examples have done for calculating what files could be compiled in parallel. Because I've now got to a point where I really need something working, I've just done it myself. ;)
My solution is pretty simple, and it basically works like it is described in the documentation for the example, walk through the tree and calculate the maximum distance. To achieve that, I'm just using the result from topological_sort and calculating the maximum through a walk through the in_edges of the vertices.
Wonderful, thank you! We'll get this fixed ASAP. Cheers, Doug
Douglas Gregor wrote:
My solution is pretty simple, and it basically works like it is described in the documentation for the example, walk through the tree and calculate the maximum distance. To achieve that, I'm just using the result from topological_sort and calculating the maximum through a walk through the in_edges of the vertices.
Wonderful, thank you! We'll get this fixed ASAP.
Thanks a lot. The only problem I'm seeing is that my solution uses a bidirectional graph because of the in_degree iterators I'm using. I've done it this way, because this was the easiest (and first) solution which has come to my mind and I've just wanted something which really works. But maybe, if someone with a better knowledge of the BGL than I will have a look at the example, he gets an idea how to do it without a bidirectional graph. ;) Kind regards, Alexander Holler
participants (2)
-
Alexander Holler
-
Douglas Gregor