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

Specify the edge when applying remove_edge #1261

Open
yulunwang opened this issue Aug 1, 2024 · 2 comments
Open

Specify the edge when applying remove_edge #1261

yulunwang opened this issue Aug 1, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@yulunwang
Copy link

yulunwang commented Aug 1, 2024

What is the expected enhancement?

Currently the method rustworkx.PyGraph.remove_edge is only taking parent and child as input:
def remove_edge(self, parent: int, child: int, /) -> None: ...
In the function description, it says:

Note if there are multiple edges between the specified nodes only one will be removed.

But this is ambiguous. Which one of these edge will be exactly removed? It seems random and it caused some trouble.
Can you please modify the function input so we can specify edge to be removed?
Just like add_edge(self, parent: int, child: int, edge: _T, /) function

@IvanIsCoding
Copy link
Collaborator

As you can see PyGraph.remove_edge was not designed with multigraphs in mind. The functionality you want though, already exists with PyGraph.remove_edge_from_index. If you want to delete a specific edge between the many edges between nodes A and B, you will need to disambiguate with the edge index.

Maybe a follow up question is on how to find the edge index. The most straightforward way is to keep the index from PyGraph.add_edge or related methods, that for sure works. But let's say that is not possible, you can still query all edge indices with PyGraph.edge_indices_from_endpoints and then narrow down the edge you want to delete.

I think there might be a value adding a function such as PyGraph.remove_matching_edges(parent, child, value). But we will need to narrow down if we want to remove one occurrence, all occurrences or let the user specify how many values they want removed.

@IvanIsCoding IvanIsCoding added the enhancement New feature or request label Aug 2, 2024
@ranjana-mishra
Copy link

@yulunwang if you specify exactly except what is provided by PyGraph.remove_edge_from_index, what you want to achieve , I can work on that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants