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

Wishlist: Support reading/writing the graph6 format #1074

Open
szhorvat opened this issue Mar 13, 2018 · 12 comments · May be fixed by #2526
Open

Wishlist: Support reading/writing the graph6 format #1074

szhorvat opened this issue Mar 13, 2018 · 12 comments · May be fixed by #2526
Assignees
Labels
wishlist Feature request that has not been chosen for implementation yet; vote or comment to prioritize it!
Milestone

Comments

@szhorvat
Copy link
Member

This is a suggestion to support the graph6, sparse6 and digraph6 file formats. These are used by the nauty suite. Nauty comes with many command line tools that read and write graphs to stdin/stdout in these formats. Supporting them allows easy interoperability with these tools.

This format is primarily relevant for graph theory (not network science / data analysis).

Here's the format description: https://users.cecs.anu.edu.au/~bdm/data/formats.html

The tools to look at for implementation guidance are showg and listg.

Note: I won't work on this myself because the current import/export design in igraph is not easy to integrate into Mathematica due to the use of FILE * pointers and the stdio framework (i.e. I can't hook the functions up to custom streams).

@szhorvat szhorvat changed the title Wishlist: support graph6 Wishlist: Support reading/writing the graph6 format Mar 13, 2018
@stale
Copy link

stale bot commented Jan 22, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issues that have been inactive for a long time; will be closed in the absence of further activity label Jan 22, 2020
@szhorvat szhorvat added the wishlist Feature request that has not been chosen for implementation yet; vote or comment to prioritize it! label Jan 22, 2020
@stale stale bot removed the stale Issues that have been inactive for a long time; will be closed in the absence of further activity label Jan 22, 2020
@szhorvat
Copy link
Member Author

It may be more useful to first create a function that takes a graph6 string (not a file) as input and creates a graph from it. Permission was granted (in private) to re-use code from gtools/nauty for this. (The license is not GPL2-compatible, so we could not just rely on that.)

@tjsavitsky
Copy link

I use both nauty and igraph, and I think that implementing nauty's graph formats (graph6, sparse6, and digraph6) in igraph would be helpful. I find the graph6 format particularly convenient since it compactly encodes simple graphs as strings of ASCII characters. If such functionality were implemented in igraph, would it make more sense to work with C-style strings or igraph vectors of chars?

@szhorvat
Copy link
Member Author

Reading nauty strings (graph6/digraph6/sparse6, but not incremental sparse6) is already implemented in the Mathematica interface of igraph. It just needs to be ported over to C. It's not that hard to do but I was going to wait until writing nauty string is also implemented. Would the one-way conversion already be useful to you @tjsavitsky? If yes, we can make it happen for igraph 0.9.

@tjsavitsky
Copy link

Yes, being able to read the nauty formats would be helpful. Thanks!

@szhorvat szhorvat added this to the 0.9.0 milestone Jul 23, 2020
@szhorvat
Copy link
Member Author

OK, time allowing I'll port over the implementation I did for IGraph/M. It should be easy.

May I ask which language you use igraph from? (C, R, Python, Mathematica?)

@szhorvat
Copy link
Member Author

@tjsavitsky If you have the expertise and the time to contribute a function to convert an igraph_t to a graph6/digraph6/sparse6 string, that would be very much appreciated. If you decide to give it a try, let me know in advance. I'll be happy to give some guidance. Note that we have permission to re-use code from nauty that deals with reading/writing these formats (only for these parts!).

The format description is here:

https://users.cecs.anu.edu.au/~bdm/data/formats.html

https://users.cecs.anu.edu.au/~bdm/data/formats.txt

sparse6 in particular seems to be a bit fussy to deal with, so re-using nauty's original code is not a bad idea. It would reduce the likelihood of bugs.


As for the reverse conversion (nauty -> igraph), that's mostly done, so we don't need help with it.

@szhorvat
Copy link
Member Author

If such functionality were implemented in igraph, would it make more sense to work with C-style strings or igraph vectors of chars?

I would say C style strings.

All uses of igraph_vector_char_t that I could find are numeric (not for storing text).

@ntamas @gaborcsardi Do the R/Python interfaces give us any reason to choose igraph_vector_char_t over char *? (I don't expect so.)

@ntamas
Copy link
Member

ntamas commented Jul 23, 2020

Nope, just go with C strings; Python can convert from a Python string to a C string but not to an igraph_vector_char_t.

@lichengzhang1
Copy link

In the Python version of igraph, has the conversion of graph6 been implemented?

@ntamas
Copy link
Member

ntamas commented Mar 4, 2024

No, it's not even in the C core.

@szhorvat
Copy link
Member Author

szhorvat commented Mar 4, 2024

It's a work in progress, see #2526

@szhorvat szhorvat linked a pull request Apr 30, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wishlist Feature request that has not been chosen for implementation yet; vote or comment to prioritize it!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants