Skip to content

Adds postprocessing to approximate dominating set. - #1573

Draft
jfinkels wants to merge 1 commit into
networkx:mainfrom
jfinkels:approx-domset-postprocess
Draft

jfinkels wants to merge 1 commit into
networkx:mainfrom
jfinkels:approx-domset-postprocess

Conversation

@jfinkels

@jfinkels jfinkels commented Jun 9, 2015

Copy link
Copy Markdown
Contributor

Improves the approximate dominating set algorithm by reducing redundancy
in the returned dominating set. This is an optional optimization that is
disabled by default, since it comes at the expense of increased running
time.

Fixes issue #1572 by modifying code provided by @bbphd in a comment on issue #1566. However, there are still some tasks before this can be merged, mainly to determine the running time if the postprocessing option is enabled, and whether it should be enabled by default.

@bbphd

bbphd commented Jun 9, 2015

Copy link
Copy Markdown

The two references that describe the method do not comment on the time it takes. And both did extensive simulations and used this method as their default. I believe it's likely that the additional run time is trivial in the typical case of these simulations, but worst case, I don't know, and one should also consider the possibility that my implementation could be less efficient than theirs. Perhaps tomorrow I'll try to figure out the worst case complexity. Also note one preprint http://arxiv.org/abs/1305.3584 found measurable improvement using this step on large random graphs, and chose to implement it by default rather than a more interesting recursive method they apparently invented..

@bbphd

bbphd commented Jun 18, 2015

Copy link
Copy Markdown

Your code seems good to me, except defining redundancy for G rather than dom_set is a wasteful error, so I fixed that in the gist below (tried to use Git-Hub Mac, but it did not work--no permission or ??). I also improved on my test case and added that to the test file on the same Gist. I left the old test case in there since it's not hurting anything right now. Still to do, if we had a test case that required a maximal number of postprocessing steps we could decide whether to enable that by default... although there is some logic to using the simplest greedy algorithm as long as users realize they'll do better with postprocessing, probably at minimal cost.
https://gist.github.com/bbphd/1e398acc2e78e437df03

@bbphd

bbphd commented Jul 12, 2015

Copy link
Copy Markdown

I did find a second subtle bug that was in the original code and fixed it in my updated Gist revision to the jfinkels version that I posted above. In the denominator of the cost function we must subtract the dom_set and its neighborhoods, which is equivalent to intersecting with the remaining vertices. I've been testing the code on problems with |dom_set| of order 1500 and it works great, and the postprocessing does give an improvement at a speed cost of only 1% to 3% in the data sets I used. That's the good news. (I think this should be merged because it works and the old code really doesn't.) The bad news is for large problems our speed is not good, and I found a paper that explains the situation well
http://dimacs.rutgers.edu/~graham/pubs/papers/ckw.pdf
Of the two "canonical" implementations in that paper, we have chosen the slower one, and I think we're in a good position to use the faster one because in dominating set (versus set cover) we already have the reverse index by just traversing to all nodes within radius 2. I am hoping someone is up to coding this. I have some ideas about how one might do it, but I'm not confident given my lack of python experience and non-CS background...

@bbphd

bbphd commented Jul 18, 2015

Copy link
Copy Markdown

I've taken a crack at implementing a heap priority queue version, and posted it on a separate file in the same Gist as above. It is fast but currently has a bug or two. With post_process = True it doesn't even always return a dominating set. I used the heapq wrapper in the docs but I eliminated the order counter because I don't think we need it, but perhaps that breaks it somehow. It does give the right answer on some small examples....

@jfinkels
jfinkels force-pushed the approx-domset-postprocess branch from 8787a81 to 4f750af Compare July 20, 2015 04:19
@jfinkels

Copy link
Copy Markdown
Contributor Author

I just updated this pull request with your suggested test cases and changed the for u in G to for u in dom_set. Why don't we just consider the changes in this pull request only for now, and then when you have completed all the updates you wish to make to the approximate dominating set algorithm, submit them as a separate pull request. Here are some articles about how to create code in your own branch and create a pull request: https://help.github.com/categories/collaborating/

@bbphd

bbphd commented Jul 20, 2015

Copy link
Copy Markdown

I'm in agreement except I also think it imperative to fix the cost function (line 107) ; instead of
return G.node[v].get(weight, 1) / len(neighborhood - dom_set)
it should be
return G.node[v].get(weight,1)/len(neighborhood & vertices )

@jfinkels

jfinkels commented Jul 20, 2015 via email

Copy link
Copy Markdown
Contributor Author

@jfinkels
jfinkels force-pushed the approx-domset-postprocess branch from 4f750af to a45fd1a Compare July 21, 2015 14:03
@jfinkels

Copy link
Copy Markdown
Contributor Author

Okay, this branch is ready to be reviewed and merged. Any other changes by @bbphd should come in a different pull request.

@bbphd

bbphd commented Jul 21, 2015

Copy link
Copy Markdown

Well, I got the new fast version working sooner than I thought. I believe
it goes as N log N instead of N^2. On a real world graph with a solution
of size ~1500 it takes 0.25 seconds instead of 10 seconds. It is
available as dom_set_fast in the same Gist. I will look into what is
involved in making a pull request ...

On Sun, Jul 19, 2015 at 10:22 PM, jfinkels [email protected] wrote:

I just updated this pull request with your suggested test cases and
changed the for u in G to for u in dom_set. Why don't we just consider
the changes in this pull request only for now, and then when you have
completed all the updates you wish to make to the approximate dominating
set algorithm, submit them as a separate pull request. Here are some
articles about how to create code in your own branch and create a pull
request: https://help.github.com/categories/collaborating/

—
Reply to this email directly or view it on GitHub
#1573 (comment).

Improves the approximate dominating set algorithm by reducing redundancy
in the returned dominating set. This is an optional optimization that is
disabled by default, since it comes at the expense of increased running
time.
@jfinkels
jfinkels force-pushed the approx-domset-postprocess branch from a45fd1a to 5620299 Compare November 16, 2015 21:39
@hagberg hagberg added this to the networkx-future milestone Dec 27, 2015
@hagberg
hagberg marked this pull request as draft June 25, 2020 21:02
Base automatically changed from master to main March 4, 2021 18:20

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants