Boost logo

Boost Users :

From: TC MA (maottawa3_at_[hidden])
Date: 2004-11-23 20:57:58


Fixed compile error, but has run time error.
Modified graph_property.cpp:

int
main()
{
  using namespace boost;
  using std::string;

  typedef adjacency_list<vecS, vecS,
directedS,no_property,
    property<edge_index_t, int>,
    property<graph_name_t, string> > graph_t;

  graph_t g;
  get_property(g, graph_name) = "graph";

  std::cout << "name: " << get_property(g, graph_name)
<< std::endl;

  typedef subgraph<graph_t> 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

> 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
property using property<graph_name_t, string> (see
below).
>
> typedef adjacency_list<vecS, vecS,
> directedS,no_property, edgeStruct, graphStruct>
> graph_t;
>
> Change this to:
>
> typedef adjacency_list<vecS, vecS, directedS,
no_property, edgeStruct,
> property<graph_name_t, string> > 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<graph_t> 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<vecS, vecS, directedS,
no_property, property<edge_index_t, int, edgeStruct>,
> property<graph_name_t, string> > 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
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


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