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

[QST]: How to (Add/Remove edges) from a graph? #4377

Closed
2 tasks done
Ibrahim25-ai opened this issue Apr 28, 2024 · 1 comment
Closed
2 tasks done

[QST]: How to (Add/Remove edges) from a graph? #4377

Ibrahim25-ai opened this issue Apr 28, 2024 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@Ibrahim25-ai
Copy link

Ibrahim25-ai commented Apr 28, 2024

rmm::device_uvector<int64_t> d_edge_srcs(srcs.size(), stream1);
rmm::device_uvector<int64_t> d_edge_dsts(dsts.size(), stream1);

raft::update_device(d_edge_srcs.data(), srcs.data(), srcs.size(), stream1);

raft::update_device(d_edge_dsts.data(),  dsts.data(), dsts.size(),  stream1);


    
std::optional<rmm::device_uvector<double>> d_edge_weights{std::nullopt}; 


cugraph::graph_properties_t properties{.is_symmetric = true, .is_multigraph = true};


bool renumber = true;
    cugraph::graph_t<int64_t, int64_t, false, false> graph(handle1);
    std::optional<rmm::device_uvector<int64_t>> renumber_map{std::nullopt};

std::tie(graph, std::ignore, std::ignore, std::ignore, renumber_map)  = cugraph::create_graph_from_edgelist<int64_t, int64_t, double, int64_t, int32_t, false, false>(
    handle1,
    std::nullopt, // Pass std::nullopt if no vertex ids are provided, otherwise, provide a device_uvector of vertex ids.
    std::move(d_edge_srcs),
    std::move(d_edge_dsts),
    std::move(d_edge_weights),
    std::nullopt, // std::nullopt for default vertex ids
    std::nullopt, // std::nullopt for default vertex labels
    properties,
    renumber,
    true // sorted by degree
);

the edge masking is supported in v24.04.00 ,so how i can add or remove edges without destructing the graph_t ?

Code of Conduct

  • I agree to follow cuGraph's Code of Conduct
  • I have searched the open issues and have found no duplicates for this question
@Ibrahim25-ai Ibrahim25-ai added the question Further information is requested label Apr 28, 2024
@ChuckHastings
Copy link
Collaborator

Support for dynamic graphs is in design currently. I expect that we will have a clearer concept of how we plan on handling them and what the timeline for implementation will be at some point this summer.

Removing Edges
Until the dynamic graphs feature is in place, there is no support for removing edges from a graph. You can use the edge mask to virtually remove the edges.

std::optional<cugraph::edge_property_t<decltype(graph_view), bool>> edge_mask{std::nullopt};
is a recent update to a unit test that uses edge masking. You can create an edge property (from an rmm::device_uvector that identifies which edges to mask out. They will still consume memory, and there will be a small overhead to skip them when traversing, but you should get the correct functionality and performance on edge masking is pretty good.

Adding Edges
Until the dynamic graphs feature is in place, there is no mechanism for adding edges to an existing graph without rebuilding it. If you know the entire possible edge set up front you can create the graph and use edge masking to simulate the addition of edges from the graph. If you are truly dynamically adding edges to the graph and you don't know them all a priori then you will need to recreate the graph.

Graph creation is pretty fast. If you still have the original list of edges, append the new edges to the list and create a new graph. If you don't have a copy of the original edges, you can construct a new copy from the graph using the function

decompress_to_edgelist(
which will take a cugraph::graph_view_t and generate the list of edges that are part of it. Appending your new edges to this structure you should be able to create the new graph.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants