Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost Graph some newbie questions
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2010-03-30 12:17:58


On Tue, 30 Mar 2010, Michał Nowotka wrote:

> Thanks, you helped me o lot. Answers for questions 1,2 and 4 are clear for me.
> In question 3 I don't know how to define vertex_position (what type it
> has?) and how to retrieve actual vertex positions from it?

You just define a property map (either internal or external) whose value
type is rectangle_topology<>::point_type and pass that into the algorithm
as the position map. That type has operator[] to get individual
coordinates (0 for x, 1 for y).

> And one more question:
>
> Given a graph of type boost::adjacency_matrix<boost::directedS> how
> can I access (directly) adjacency matrix for this graph?
> I suppose this graph is based on same std container. I want to use
> some genetic algorithm with genetic operators that should be able to
> operate directly on such container in order to (for example) flip some
> items or invert random selected items.

I do not believe there is an "official" way to do that -- you can use
add_edge and remove_edge, and those are reasonably direct (when your edges
don't have properties). The m_matrix member is (unofficially) public, so
you can get to the raw matrix, but what is stored in there is complicated
and it has a triangular layout for undirected graphs. Try using edge(),
add_edge(), and remove_edge() and see if those are too slow before using
internal details.

-- Jeremiah Willcock


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net