Thinklab-SJTU / pygmtools

A Python Graph Matching Toolkit.
https://pygmtools.readthedocs.io/
Other
310 stars 20 forks source link

Read and Write graph format? #90

Closed grdiv closed 12 months ago

grdiv commented 12 months ago

Can I load the graph saved by boost.graph or networkx? For example, graphml format.

rogerwwww commented 12 months ago

Yes you can. See this function https://pygmtools.readthedocs.io/en/latest/api/_autosummary/pygmtools.utils.build_aff_mat_from_graphml.html#pygmtools.utils.build_aff_mat_from_graphml

grdiv commented 12 months ago

Yes you can. See this function https://pygmtools.readthedocs.io/en/latest/api/_autosummary/pygmtools.utils.build_aff_mat_from_graphml.html#pygmtools.utils.build_aff_mat_from_graphml

Yes, thx. After I edit issues I found it, and also: https://pygmtools.readthedocs.io/en/latest/api/_autosummary/pygmtools.utils.from_graphml.html.

But I just use it, and there is an error: "../pygmtools/utils.py", line 1481, in from_networkx adj_matrix = nx.to_numpy_matrix(G,nodelist=G.nodes()) if is_directed else nx.to_numpy_matrix(G). So from networkx 3.0 should use to_numpy_array.

rogerwwww commented 12 months ago

Thanks for the update. We also have pygm.utils.build_aff_mat_from_networkx and can you please check if it accepts your data? If not, can you please provide a minimal example of the error you mentioned (also your networkX version) so that we can resolve it.

rogerwwww commented 12 months ago

cc @heatingma

grdiv commented 12 months ago

Thanks for the update. We also have pygm.utils.build_aff_mat_from_networkx and can you please check if it accepts your data? If not, can you please provide a minimal example of the error you mentioned (also your networkX version) so that we can resolve it.

I just have a map.graphml file saved by boost.graph. And when I use pygmtools to deal with, It will have that error, either build_aff_mat_from_graphml() or from_graphml(). Because my networkx is 3.2.1, 3.0 changelog has removed to_numpy_matrix.

This is a small question, I just replace to_numpy_matrix by to_numpy_array in https://github.com/Thinklab-SJTU/pygmtools/blob/5795e2b21309f6beb690df4edd5d4c8599d60bac/pygmtools/utils.py#L1481.