On Nov 23, 2004, at 11:23 AM, TC MA wrote:
struct graphStruct {
string name;
};
Unfortunately, bundled graph properties aren't
supported (yet). You can, however, add a graph name
Fixed compile error, but has run time error.
Modified graph_property.cpp:
int
main()
{
using namespace boost;
using std::string;
typedef adjacency_list,
property > graph_t;
graph_t g;
get_property(g, graph_name) = "graph";
std::cout << "name: " << get_property(g, graph_name)
<< std::endl;
typedef subgraph subgraph_t;
subgraph_t sg;
get_property(sg, graph_name) = "subgraph";
std::cout << "name: " << get_property(sg,
graph_name) << std::endl;
return exit_success;
}
Output:
$ bjam
...found 409 targets...
...updating 4 targets...
gcc-C++-action
/home/tcma/cpp/boosttcma/libs/graph/graph_property.test/gcc/debug/inlining-on/graph_property.o
gcc-Link-action
/home/tcma/cpp/boosttcma/libs/graph/graph_property
Chmod1
/home/tcma/cpp/boosttcma/libs/graph/graph_property
execute-test
/home/tcma/cpp/boosttcma/libs/graph/graph_property.run
====== BEGIN OUTPUT ======
EXIT STATUS: 139
====== END OUTPUT ======
/home/tcma/cpp/boosttcma/libs/graph/graph_property
>
/home/tcma/cpp/boosttcma/libs/graph/graph_property.output
2>&1
status=$?
echo >>
/home/tcma/cpp/boosttcma/libs/graph/graph_property.output
echo EXIT STATUS: $status >>
/home/tcma/cpp/boosttcma/libs/graph/graph_property.output
if test $status -eq 0 ; then
cp -f
/home/tcma/cpp/boosttcma/libs/graph/graph_property.output
/home/tcma/cpp/boosttcma/libs/graph/graph_property.run
fi
verbose=1
if test $status -ne 0 ; then
verbose=0
fi
if test $verbose -eq 0 ; then
echo ====== BEGIN OUTPUT ======
cat
/home/tcma/cpp/boosttcma/libs/graph/graph_property.output
echo ====== END OUTPUT ======
fi
exit $status
...failed execute-test
/home/tcma/cpp/boosttcma/libs/graph/graph_property.run...
...removing
/home/tcma/cpp/boosttcma/libs/graph/graph_property.run
...failed updating 1 target...
...skipped 1 target...
...updated 2 targets...
$ cat graph_property.output
EXIT STATUS: 139
The expected output should be:
$ cat graph_property.output
name: graph
name: subgraph
EXIT STATUS: 0
property using property (see
below).
typedef adjacency_list
graph_t;
Change this to:
typedef adjacency_list
property > graph_t;
g[e].name = "graphname";
std::cout << "name: " << g[e].name << std::endl;
These two won't compile because we can't get at the
graph properties that way. "e" is an edge descriptor,
so "g[e]" is going to give you an edgeStruct& back
(that's how we were able to set the edge weight ). To
get to the graph_name property we just added above,
use:
get_property(g, graph_name);
If we can come up with a better syntax for the
future, we'll definitely do it. For now, we're stuck
with that mess.
typedef subgraph subgraph_t;
You're actually going to run into a minor problem
here, because the subgraph adaptor requires an
edge_index property that we haven't provided. The
easiest way to introduce such a property is to
actually mix bundled and non-bundled parameters, like
so:
typedef adjacency_list,
property > graph_t;
Notice how we put in the edge_index_t property, but
ended with an "edgeStruct"? That allows, e.g.,
g[e].weight to still work, but the subgraph can use
no_property, edgeStruct,
the edge index property map directly.
subgraph_t sg;
get_property(sg, graph_name) = "subgraph";
std::cout << "name: " << get_property(sg,
graph_name) << std::endl;
return exit_success;
}
All of this is fine; it's actually what we changed
the above code to.
As you can probably tell, we're still working out
some of the kinks in the bundled properties setup.
It's better than what we had before, but we still have
a bit of work to do to make it really slick.
Doug
=====
TingChong Ma
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca