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

[BUG] Extract subgraph on pg creates an undirected graph #2457

Closed
VibhuJawa opened this issue Jul 28, 2022 · 5 comments
Closed

[BUG] Extract subgraph on pg creates an undirected graph #2457

VibhuJawa opened this issue Jul 28, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@VibhuJawa
Copy link
Member

Describe the bug

Extract subgraph on a PG creates an undirected graph instead of directed one

Steps/Code to reproduce bug

import cugraph
import cudf
from cugraph.experimental import PropertyGraph

# create PG
df = cudf.DataFrame({'src':[1,2], 'dst':[2,3]})
pg = PropertyGraph()
pg.add_edge_data(df, vertex_col_names=['src','dst'])

# extract subgraph
graph = pg.extract_subgraph()
print(graph.directed)

False
print(graph.edges())

   src  dst
0    2    3
1    1    2

Expected behavior

I would expect a directed graph.

Additional context
This means that i cant use this extracted subgraph for sampling in GNN pipe-lines.

CC: @rlratzel , @alexbarghi-nv

@VibhuJawa VibhuJawa added bug Something isn't working ? - Needs Triage Need team to review and classify GNN and removed ? - Needs Triage Need team to review and classify labels Jul 28, 2022
@VibhuJawa VibhuJawa changed the title [BUG] Extract subgraph on pg creates an undirected graph instead of directed one [BUG] Extract subgraph on pg creates an undirected graph Jul 28, 2022
@eriknw
Copy link
Contributor

eriknw commented Jul 28, 2022

Try graph = pg.extract_subgraph(cugraph.DiGraph). The first argument to extract_subgraph is create_using=cugraph.Graph.

Do you think the default should be cugraph.DiGraph?

@rlratzel
Copy link
Contributor

Try using the optional create_using arg:

graph = pg.extract_subgraph(create_using=cugraph.Graph(directed=True))

create_using accepts either a type or an instance, and uses it when creating the subgraph to return. When passing an instance, it will copy all the graph attributes (in this case, directed) when creating the new instance to return. This allows you to use any existing Graph object as a "template" when extracting subgraphs (eg. "I want a subgraph of the same type with the same options as G").

I have a test of extract_subgraph for directed graphs here as another example.

You can access the docstring of extract_subgraph using the interactive help to see all other available args:

>>> help(pg.extract_subgraph)

@rlratzel
Copy link
Contributor

(oops, Erik beat me to it)

@rlratzel
Copy link
Contributor

Try graph = pg.extract_subgraph(cugraph.DiGraph). The first argument to extract_subgraph is create_using=cugraph.Graph.

FYI, cugraph.DiGraph is deprecated in favor of the directed=True arg to the cugraph.Graph() ctor.

Do you think the default should be cugraph.DiGraph?

This is a good question, IOW, should we default to returning directed graphs if create_using isn't specified?

@VibhuJawa
Copy link
Member Author

Closing in favor of #2459 . Thanks guys .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants