rustworkx icon indicating copy to clipboard operation
rustworkx copied to clipboard

read graphs from graph6, sparse6 and digraph6 fromats

Open IbrahimElk opened this issue 4 months ago • 3 comments

What is the expected enhancement?

graph6, sgraph6 and digraph6 formats

Formal definition of these formats are available here It would the equivalent implementation of nx.from_sparse6_bytes in networkx

def from_sparse6_bytes(string)
""" Read an undirected graph in sparse6 format from string.

Parameters: string
        Data in sparse6 format

Returns: PyGraph
""""
>>> G = rx.from_sparse6_bytes(b"A_")
<rustworkx.PyGraph object at 0x7efe8bbb2c10>

IbrahimElk avatar Aug 18 '25 06:08 IbrahimElk

In the meantime, one could do one the following:

  1. read graph via networkx and use rx.networkx_converter
  2. implement a function that reads sparse6 format and manually adds nodes and edges to a PyGraph object
  3. convert sparse6 format to an equivalent graphML format

IbrahimElk avatar Aug 18 '25 06:08 IbrahimElk

This seems to be a rather niche format, but I’d accept PRs implementing it.

We can implement it from scratch or fork https://crates.io/crates/graph6-rs and adapt it to use petgraph’s graph data structures

IvanIsCoding avatar Aug 20 '25 00:08 IvanIsCoding

Hi @IbrahimElk @IvanIsCoding Please assign to me. thx~

hsunwenfang avatar Sep 01 '25 05:09 hsunwenfang