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.
New contributor
Wombat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.