read_graphml: read more than 1 graph from the same graphml file
Hello ! Is there a way a to read more than one graph from a .graphml file using read_graphml ? Here's what I tried: -open an input stream to the graphml file; -call a function to read the graph from the file (the function uses read_graphml) and print the graph to stdout; -call the same function again, hoping that the second graph from the file will be read; -close the file input stream. If I call the function once, it works fine and returns the first graph defined in the graphml file. If I call the function the twice, I get the following runtime exception: 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::property_tree::ptree_bad_path> >' what(): No such node (graphml) The graphml file looks like this : <graphml ....header stuff... > <key id= ...key definitions...> <graph id="TestSite1" edgedefault="undirected"> <node id="node0"> <data key="map">map1</data> <data key="x">5.0</data> <data key="y">1.0</data> </node> <node id="node1"> <data key="map">map1</data> <data key="x">5.0</data> <data key="y">4.0</data> </node> <edge source="node0" target="node1"/> </graph> <graph id="TestSite2" edgedefault="undirected"> <node id="node0"> <data key="map">map3</data> <data key="x">6.0</data> <data key="y">2.0</data> </node> <node id="node1"> <data key="map">map4</data> <data key="x">7.0</data> <data key="y">9.0</data> </node> <edge source="node0" target="node1"/> </graph></graphml> I can correctly get the data of TestSite1 graph if I call the function once. How can I get the TestSite2 graph from the same file, or, for that matter, how can I get one specific graph (ex TestSiteN) ? Thanx for any help, -attoparsec-
On Mon, 12 Nov 2012, Bartha Attila wrote:
Hello !
Is there a way a to read more than one graph from a .graphml file using read_graphml ? Here's what I tried: -open an input stream to the graphml file; -call a function to read the graph from the file (the function uses read_graphml) and print the graph to stdout; -call the same function again, hoping that the second graph from the file will be read; -close the file input stream.
If I call the function once, it works fine and returns the first graph defined in the graphml file. If I call the function the twice, I get the following runtime exception: 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::property_tree::ptree_bad_ path> >' what(): No such node (graphml)
I just added this feature to the trunk in response to your question. There is now an extra parameter to read_graphml to give the zero-based index of the graph you want within the file. That isn't ideal if there are a lot of graphs in the file, but it's more reliable than what is there now. -- Jeremiah Willcock
Thank You. I will look at it. ________________________________ From: Jeremiah Willcock <jewillco@osl.iu.edu> To: "boost-users@lists.boost.org" <boost-users@lists.boost.org> Sent: Monday, November 12, 2012 11:32 PM Subject: Re: [Boost-users] read_graphml: read more than 1 graph from the same graphml file On Mon, 12 Nov 2012, Bartha Attila wrote:
Hello !
Is there a way a to read more than one graph from a .graphml file using read_graphml ? Here's what I tried: -open an input stream to the graphml file; -call a function to read the graph from the file (the function uses read_graphml) and print the graph to stdout; -call the same function again, hoping that the second graph from the file will be read; -close the file input stream.
If I call the function once, it works fine and returns the first graph defined in the graphml file. If I call the function the twice, I get the following runtime exception: 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::property_tree::ptree_bad_ path> >' what(): No such node (graphml)
I just added this feature to the trunk in response to your question. There is now an extra parameter to read_graphml to give the zero-based index of the graph you want within the file. That isn't ideal if there are a lot of graphs in the file, but it's more reliable than what is there now. -- Jeremiah Willcock _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Bartha Attila
-
Jeremiah Willcock