I tried to read a GraphML file using Douglas' code and the following:
std::auto_ptrboost::dynamic_property_map
string2string_gen(const std::string& name,
const boost::any&,
const boost::any&) {
typedef std::mapstd::string,std::string map_t;
typedef
boost::associative_property_map< std::map >
property_t;
map_t* mymap = new map_t(); // hint: leaky memory here!
property_t property_map(*mymap);
std::auto_ptrboost::dynamic_property_map pm(
new
boost::detail::dynamic_property_map_adaptor(property_map));
return pm;
}
int main(int argc, char* argv[]){
// create a typedef for the Graph type
using namespace boost;
typedef boost::adjacency_list Graph;
Graph g;
std::ifstream input(argv[1]);
boost::dynamic_properties properties(&string2string_gen);
typedef graph_traits<Graph>::vertex_descriptor Node;
typedef property_map::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" >
</data>
</node>
I am not even really interested in the d0 properties ...
What can I do?