pythonmultithreadingnetworkxgraph-theoryrapids

How to convert cuGraph directed graph to undirected to run MST?


I'm trying to build MST from a directed graph by converting it to an undirected one. I followed cuGraph example here but getting NotImplementedError: Not supported for distributed graph.

I tried doing G = cugraph.Graph(directed=False), but it still gave me an error.

My code:

columns_to_read = ['subject', 'object', 'predicate']

# Read the TSV file using Dask cuDF with specific columns
df = dask_cudf.read_csv('graph_edge.tsv', sep='\t', usecols=columns_to_read)

# Renaming columns to match cuGraph requirements
df = df.rename(columns={'subject': 'src', 'object': 'dst'})

# Create undirected graph from input data
DiG = cugraph.Graph(directed=True)
DiG.from_dask_cudf_edgelist(df, source='src', destination='dst')
G = DiG.to_undirected()

# Verify the graph has edges
print("Number of edges in the graph:", G.number_of_edges())

# Define the list of target terminals
terminals = ['COMPOUND:7045767', 'COMPOUND:0007271', 'COMPOUND:0035249', 'COMPOUND:0005947', 'COMPOUND:0004129', 
            'COMPOUND:26519', 'COMPOUND:C0132173', 'COMPOUND:0018393', 'COMPOUND:0006979', 'COMPOUND:0025464', 'COMPOUND:0007613', 
            'COMPOUND:64645', 'COMPOUND:000010173', 'COMPOUNDGO:0014055', 'COMPOUND:0061535', 'COMPOUND:0150076', 'COMPOUND:0001152', 
            'COMPOUND:0002185', 'COMPOUND:0004975', 'COMPOUND:0005816', 'COMPOUND:60425']

# Compute the minimum spanning tree of the graph
mst = cugraph.minimum_spanning_tree(G)

# Convert the resulting MST to a cuDF DataFrame
mst_df = mst.view_edge_list()

# Ensure to finalize the cuGraph communication
client.close()
cluster.close()

# Display the MST DataFrame
print(mst_df.compute())

I looked at cuGraph documentation and Stackoverflow posts, but I still get errors.


Solution

  • cugraph does not currently have a multi-GPU (distributed) implementation of MST. This is the reason you are getting the NotImplementedError: Not supported for distributed graph message. The latest detail on what algorithms are supported for multi-GPU can be found here: https://docs.rapids.ai/api/cugraph/stable/graph_support/algorithms/#supported-algorithms

    We welcome user feedback, if you would like to register your interested in a multi-GPU implementation (or any other cugraph features) you can create an issue here: https://github.com/rapidsai/cugraph/issues. A multi-GPU implementation is not currently on our development road map, although it is on the list of things to eventually get to.