Boost logo

Boost Users :

From: Jens Müller (jens.mueller_at_[hidden])
Date: 2006-10-01 10:18:13


I tried to read a GraphML file using Douglas' code and the following:

std::auto_ptr<boost::dynamic_property_map>
string2string_gen(const std::string& name,
                  const boost::any&,
                  const boost::any&) {
  typedef std::map<std::string,std::string> map_t;
  typedef
    boost::associative_property_map< std::map<std::string, std::string> >
    property_t;

  map_t* mymap = new map_t(); // hint: leaky memory here!

  property_t property_map(*mymap);

  std::auto_ptr<boost::dynamic_property_map> pm(
    new
boost::detail::dynamic_property_map_adaptor<property_t>(property_map));

  return pm;
}

int main(int argc, char* argv[]){
        // create a typedef for the Graph type
        using namespace boost;

        typedef boost::adjacency_list<vecS, vecS, directedS> Graph;
        Graph g;

        std::ifstream input(argv[1]);

        boost::dynamic_properties properties(&string2string_gen);
        typedef graph_traits<Graph>::vertex_descriptor Node;
        typedef property_map<Graph, vertex_index_t>::type NodeID_Map;

        NodeID_Map node_id = get(vertex_index, g);

        boost::read_graphml(input, g, properties);

}

but when running it I get:
Unrecognized attribute `xmlns' of element `graphml'. Ignoring...
Unrecognized attribute `xmlns:y' of element `graphml'. Ignoring...
Unrecognized attribute `xmlns:xsi' of element `graphml'. Ignoring...
Unrecognized attribute `xsi:schemaLocation' of element `graphml'.
Ignoring...
Unrecognized attribute `yfiles.type' of element `key'. Ignoring...
Unrecognized attribute `yfiles.type' of element `key'. Ignoring...
Unrecognized element `y:ShapeNode'
Unrecognized element `y:Geometry'
Unrecognized element `y:Fill'
Unrecognized element `y:BorderStyle'
Unrecognized element `y:NodeLabel'
Unrecognized element `y:Shape'
terminate called after throwing an instance of 'boost::bad_any_cast'
  what(): boost::bad_any_cast: failed conversion using boost::any_cast
/bin/sh: line 1: 31380 Abgebrochen ./src/graphml2
Core0bis10_1000.graphml

The file contains nodes like this (what a bloat ...):

<node id="n1">
      <data key="d0" >
        <y:ShapeNode >
          <y:Geometry x="2.457598996954175" y="498.06375265283157"
width="10.0" height="10.0"/>
          <y:Fill color="#FF0000" transparent="false"/>
          <y:BorderStyle type="line" width="1.0" color="#000000" />
          <y:NodeLabel x="3.0" y="3.0" width="4.0" height="4.0"
visible="true" alignment="center" fontFamily="Dialog" fontSize="12"
fontStyle="plain" textC
olor="#000000" hasBackgroundColor="false" hasLineColor="false"
modelName="internal" modelPosition="c"
autoSizePolicy="content"></y:NodeLabel>
          <y:Shape type="rectangle"/>
        </y:ShapeNode>
      </data>
    </node>

I am not even really interested in the d0 properties ...

What can I do?


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