## Tree coverage problem

Given a tree of n nodes, assign the nodes values j between 1 and n, where a node with the value j is covering itself and all nodes that are j steps away from it, such that you cover all nodes while keeping the sum of the assigned values minimal.

How would one approach such a problem ? My first idea was to use a greedy algorithm where I select the node with the lowest cost to covering ratio next, but it doesn’t seem to find the optimal solution many times.

## Cobertura (Coverage Testing Tool) : Problem with executing .jar file and displaying the form?

I want to use cobertura for coverage testing. I followed the following link:

That link provides a EC-Cobertura.jar file through download. I think it creates a parameter for passing arguments to cobertura. I am trying to run EC-Cobertura.jar but its giving me error:

:~/cobertura$$ls -l EC-Cobertura.jar -rw-rw-r-- 1 zulfi zulfi 165174 Mar 8 17:53 EC-Cobertura.jar :~/cobertura$$ java -jar EC-Cobertura.jar no main manifest attribute,in EC-Cobertura.jar

Jar file error

:~/cobertura$$chmod a+rx EC-Cobertura.jar :~/cobertura$$  ./EC-Cobertura.jar   no main manifest attribute, in cobertura/EC-Cobertura.jar :~/cobertura$I have already downloaded the cobertura and its installed on my ubuntu 18.04. :~$$whereis cobertura-instrument cobertura-instrument: /usr/bin/cobertura-instrument /usr/share/man/man1/cobertura-instrument.1.gz :~$$ And it has the same version as the tar file provides whose link is : cobertura download link provided in the link of the associated help button page: :~$$cobertura-instrument -version Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file [INFO] Cobertura: Saved information on 0 classes. [INFO] Cobertura: Saved information on 0 classes. :~$$ But the help file does not say anything about the jar file. I still don’t know how to execute the jar file and how to display the form shown on the link: plugin link Somebody please guide me how to display the form? What is the purpose of EC-Cobertura.jar in this connection. Zulfi. ## GSC Coverage vs Mobile Usability discrepancy in count I ran Excel VLOOKUP against all of the files GSC Coverage lists, versus all of the files GSC mobile usability says are mobile friendly. About 30% of the pages listed in Coverage are not included in the Mobile Usability list. However, when I run them through GSC’s URL inspection, it says that these missing pages are mobile friendly. Is this something I should be concerned about? Will this impact what URLs are visible to mobile searches? ## maximum coverage version of dominating set The dominating set problem is : Given an $$n$$ vertex graph $$G=(V,E)$$, find a set $$S(\subseteq V)$$ such that $$|N[S]|$$ is exactly $$n$$, where $$N[S] := \{x~ | \text{ either x or a neighbor of x lies in S }\}$$ My question is if the following (new problem) has a definite name in literature, and if not what should be the most appropriate name. New Problem: Given an $$n$$ vertex graph $$G=(V,E)$$ and an integer $$k$$ , find a set $$S(\subseteq V)$$ of size $$k$$ such that $$|N[S]|$$ is maximized. For the second problem, some of the names I have seen in the literature are maximum-graph-coverage; partial-coverage; k-dominating-set, (however, the exact same names are also used in other contexts). ## See Index Coverage Report Not Working (not able to click) Hy I suddenly facing the problem in google webmaster tool that about 1 week the “see index coverage” is not working.(not able to click to see index and submitted urls in sitemap) Not able to click I also resubmit sitemap to all versions but not working. ## Finding vertex coverage that is also independent set Given a graph G and integer k, find a vertex coverage set of size k that is also an independent set. I need to either prove this problem is np-complete or find a polynomial solution. Any idea ? Thanks! ## Tight analysis for the ration of$1-\frac{1}{e}\$ in the unweighted maximum coverage problem

The unweighted maximum coverage problem is defined as follows:

Instance: A set $$E = \{e_1,…,e_n\}$$ and $$m$$ subsets of $$E$$, $$S = \{S_1,…,S_m\}$$.

Objective: find a subset $$S’ \subseteq S$$ such that $$|S’| = k$$ and the number of covered elements is maximized.

The problem is NP-hard, but a simple greedy algorithm (at each stage, choose a set which contains the largest number of uncovered elements) achieves an approximation ratio of $$1-\frac{1}{e}$$.

In the following post, there is an example of when the greedy algorithm fails.

Tight instance for unweighted maximum coverage problem?

I wish to prove that the approximation ration for the greedy algorithm is tight. That is, the greedy algorithm is not an $$\alpha-$$approximation ratio for any $$\alpha > 1-\frac{1}{e}$$.

I think that if I will find, for any $$k$$, (or for an ascending series of $$k’s$$), an instance where the number of elements covered by greedy algorithm is $$1-(1- \frac{1}{k})^k$$ times the number of elements covered by the optimal solution, the tightness of the ratio will be proved.

Can someone give a clue for such instances?

I thought of an initial idea: let $$E = \{ a_1 ,…a_n,b_1,…,b_n,…,k_1,…,k_n\}$$, a set with $$n\cdot k$$ elements. Let $$S$$ include $$k$$ sets of $$n$$ elements each, $$A = \{ a_1 ,…a_n\},…,K= \{k_1,…,k_n\}$$. The optimal solution will select these $$k$$ sets and cover all the elements in $$E$$. Now I want to add $$k$$ sets to $$S$$, that will be the solution the greedy algorithm will find, and will cover $$1-(1- \frac{1}{k})^k$$ of the elements in $$E$$. The first such set, of size $$n$$: $$S_1 = \{a_1,…a_\frac{n}{k},b_1,…b_\frac{n}{k},…,k_1,…k_\frac{n}{k} \}$$ ($$\frac{n}{k}$$ elements from each of the first $$k$$ sets). The second such set, of size $$n – \frac{n}{k}$$: $$S_2 = \{a_\frac{n}{k},…a_{\frac{n}{k}+ (n – \frac{n}{k})\cdot\frac{1}{k}},b_\frac{n}{k},…,b_{\frac{n}{k}+ (n – \frac{n}{k})\cdot\frac{1}{k}},…,k_\frac{n}{k},…,k_{\frac{n}{k}+ (n – \frac{n}{k})\cdot\frac{1}{k}} \}$$ , (that is, $$(n – \frac{n}{k})\cdot\frac{1}{k}$$ elements from each of the first $$k$$ sets) and so on till we have $$k$$ additional such sets.

I don’t think this idea works for every $$k$$ and $$n$$, and I’m not sure it’s the right approach.

Thanks.

## Code Coverage and Defensive Programming (in private functions)

Assuming you want to build automated tests for the following (very simple, if odd) class.

// Calculates the distance between neighboring values in a vector // and provides functions to return the distance from one index to the following // or to find the first occurrence of a specified distance class NeighborDistanceFinder {   public:     NeighborDistanceFinder(std::vector<int> inputVector)         : m_neighborVector(inputVector) { };      int getDistanceToNextIndex(int index) const     {         if (index >= 0 && index < m_neighborVector.size() - 1)             return calculateDistance(index, index + 1);         throw "Provided index is invalid";     }      int getIndexOfFirstOccurenceOfDistance(int distance) const     {         for (int index = 0; index < m_neighborVector.size() - 1; i++)         {             if (calculateDistance(index, index + 1) == distance)                 return index;         }         throw "Distance not found";     }    private:     std::vector<int> m_neighborVector;      int calculateDistance(int index, int otherIndex) const     {         const int lastIndex = m_neighborVector.size() - 1;         if (index < 0 || otherIndex < 0 || index > lastIndex  || otherIndex > lastIndex)             throw "Index of of bounds"; //This should never happen         return m_neighborVector.at(index) - m_neighborVector.at(otherIndex);     } }

In such a simple class the bounds check for calculateDistance() is probably overkill, but imagine the condition to check being more complex than a simple bounds check and more functions calling calculateDistance(), functions mucking around with m_neighborVector and soon it looks more and more appealing…

In any case, with this masterwork at hand we suddendly realize we did not do TDD and don’t have any unit tests. Well, no fear, they are simple enough to add (… a few hours later …). Done.

But there is a gap in in our code coverage: we cannot reach throw "Index of of bounds"; (unless I made a mistake in writing this example…). Well, of course, we catch the out-of-bounds cases in the two public functions invoking it, and the function is private so we cannot invoke it directly (as we lack reflection in C++). I know, static code analysis should be able to tell us that this is essentially dead code, but again: Imagine the condition being more complex.

So what should be done concerning this very-defensive private function at this point?

1. The gap is fine – you don’t need (and will never get) 100% coverage – just move on.
2. This is overkill defensive programming in a private function – get rid of the check, FFS.
3. You need to cover this – move the function to protected or make your test a friend class etc.
4. And now for something completely different?

## Method Code Coverage not covering incase of calling flatMap() in Spring Reactor

First take a look inside the code

WebClient client = WebClient.create("TEMP URL);          Mono<Employee> employeeMono = client.get()                 .uri("temp url")                 .accept(MediaType.APPLICATION_JSON)                 .retrieve()                 .bodyToMono(Employee.class);          return employeeMono.flatMap(this::employeeMapper);      public EmployeeDTO employeeMapper(Employee employee){     //     //     //     //     }

I’m calling Code coverage in IntellijIDEA, all lines are covered but employeeMapper() unable in case of if I using Mono with FlatMap method.

I need to covered the employeeMapper(), please suggest me what should I need to do so that code inside the employeeMapper() also covered.

Please let me know in case you need more clarification.

## Adding RSpec coverage for a method with if/else logic

So I am fairly new to RSpec and Rails and I’ve been trying to learn RSpec as much as possible and I am really struggling with implementing coverage for methods that contain logic in them.

The app that I am practicing with uses coverage percentages to make sure I am properly covering the code I am implementing and I am missing coverage on the following method: