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

Added a function to delete a Node and its associated Edges #24

Merged
merged 2 commits into from
May 4, 2021

Conversation

EwenQuim
Copy link
Contributor

@EwenQuim EwenQuim commented May 2, 2021

Added a function and its corresponding Test.
Tests pass 100%.
I need it for my project, is it ok for you to integrate it in your lib ?

A fellow golang dev,
Best

graph.go Outdated Show resolved Hide resolved
// Remove all the edges to the Node
for parent, edgeList := range g.edgesFrom {
for i, edge := range edgeList {
if edge.to.id == id {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this can be done more efficiently; break the loop after deletion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this one, because two nodes A & B can have several edges going from A to B (happens in my project). The complexity is bad (the average is the number of edges...) but I don't think there is another way to do so, and removing a node should be a one-time operation, not something to be optimized. But that's your lib, don't hesitate to tell me what you think about this :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are probably right. and again, the whole lib is not build for performance.

graph_test.go Show resolved Hide resolved
graph.go Outdated Show resolved Hide resolved
@EwenQuim
Copy link
Contributor Author

EwenQuim commented May 3, 2021

Coverage is now 92.2, sorry for the force push, i just forgot things in my last commit so I --amend'ed them

@EwenQuim EwenQuim requested a review from emicklei May 4, 2021 09:45
@emicklei emicklei merged commit 6136323 into emicklei:master May 4, 2021
@emicklei
Copy link
Owner

emicklei commented May 4, 2021

thank you for contributing @EwenQuim

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

Successfully merging this pull request may close these issues.

None yet

2 participants