Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any method to save the ContractionHierarchy in files using jgrapht #1126

Open
linxinyaooo opened this issue Sep 7, 2022 · 2 comments

Comments

@linxinyaooo
Copy link

 * JGraphT version: 1.4.0
 * Java version (java -version)/platform:  
openjdk version "18.0.2" 2022-07-19
OpenJDK Runtime Environment (build 18.0.2+9-61)
OpenJDK 64-Bit Server VM (build 18.0.2+9-61, mixed mode, sharing)

Issue

I have used jgrapht to analyse some graph problems. Now I am working with big graph (with more than ten millions nodes ) and use CH algorithm.

What troubles me is the precomputation of CH is so long, more than 2 hours. And I found the preprocessed data is saved in ContractionHierarchy as below.

Steps to reproduce (small coding example)

public static class ContractionHierarchy<V, E>

Expected behaviour

So I wonder is there any way to export ContractionHierarchy to files so that I can use it next time without compiling the precomputation and query directly.

Other information

@jsichi
Copy link
Member

jsichi commented Sep 9, 2022

It doesn't appear possible, currently. And I agree that it would be very useful to add this.

The simplest way would be to mark the inner class ContractionHierachy as Serializable, and then test to see what else needs to be done to support successful serialization and deserialization.

However, this isn't necessarily the best approach, since it requires serializing the underlying graph as well, which may contain information which isn't relevant to the contraction itself. Also, Java serialization comes with other issues such as incompatibilities across versions.

I can think of other ways which build off of our graph export/import packages, allowing the contraction graph itself to be saved in arbitrary format, separate from the underlying graph. This requires the inner classes to be made public.

@linxinyaooo
Copy link
Author

It doesn't appear possible, currently. And I agree that it would be very useful to add this.

The simplest way would be to mark the inner class ContractionHierachy as Serializable, and then test to see what else needs to be done to support successful serialization and deserialization.

However, this isn't necessarily the best approach, since it requires serializing the underlying graph as well, which may contain information which isn't relevant to the contraction itself. Also, Java serialization comes with other issues such as incompatibilities across versions.

I can think of other ways which build off of our graph export/import packages, allowing the contraction graph itself to be saved in arbitrary format, separate from the underlying graph. This requires the inner classes to be made public.

Thank you for your reply. it helps me a lot : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants