Find optimal subset using max flow

Let’s say that you want to invite a person u in P. The person u will join the party if and only if all the friends of u will join the party as well. Otherwise, u will reject your invitation. Hence, we have to sets: P with all the persons, and F with the friend relations. Suppose (u, v) belongs to F. This means that u treats v as a friend of u, and thus u will reject your invitation if v does not join the party. Note that (u, v) ∈ F doesn’t mean that v treats u as a friend of v. Also, every person u in P has a quality measure, pu (this can be positive or negative and is given). Now I need to find a subset of P, such that all those in the subset won’t reject my invitation and the qualities among the people is maximized.

Here is an example of a feasible and non-feasible subset: P = {a, b, c, d}, F = {(a, b),(a, c),(b, d),(b, c)}, pa = 10, pb = 1, pc = 1, pd = −20. A subset {a, b, c} is not feasible because d is not invited and thus b rejects your invitation. A subset {b, c, d} is feasible with total quality is pb + pc + pd = −18 which is not maximized. The optimal subset A of this example is {c} with total quality is pc = 1.

Now I need to design an algorithm that finds this optimal subset in O(|P|(|P| + |F|)²) time. My thoughts: The elements in F are directed edges, and the elements in P are the nodes. As we are kind off dealing with a maximum flow problem, and as the required running time resembles the running time of the Ford Fulkerson algorithm O(VE²), I thought, that (|P| + |F|) should be the amount of edges in the graph. Hence, my thought was to split each node u into two nodes, say u(in) and u(out) with the directed arc u(in)->u(out) and edge weight the pu. This way we have (|P| + |F|) edges. However, the max flow algorithm doesn’t necessarily saturate the edges it travels. However, in my case, whenever a node is reached (person is invited)/edge is travelled it adds the full flow pu.

How would youapproach this problem? And what are your thoughts on how the algorithm should work?

Dynamic programming algorithm with an O(n) performance that will give the optimal solution

I am currently learning the dynamic substructure and optimal solution for the coin change-making, and one of the questions given from my teacher is to describe an overall O(n) dynamic programming algorithm that will give the optimal solution and why is it O(n)? Can anyone help me to understand the question? Thank you!

Optimal distribution of N points in non euclidean volume, where each point is furthest away from the others

Given N points, I want to find the optimal configuration for which all the points are as far away from each other as possible.

The metric I’m considering is an approximation to the perceived distance between two colors:






The colors are constrained between 0 and 255. And there are N colors of maximum pair distance I want to find, in addition to these N colors, there’s a point in the origin (black) and in the topmost right-front corner (white) which are fixed in place.

This reminds me of sphere packing, but I don’t know the optimal size of the sphere so that they’d fill the whole volume… And since this metric is not translation invariant, I’m not sure how to calculate the sphere positions even if I knew the sphere size.

I’ve tried minimizing some cost functions, such as


or the columb force inspired


But it’s not very efficient, and is very dependent on initial guess (and it seems my euclidean grid-based guess isn’t optimal).

Is there a generalized form of the sphere packing algorithm which would give me the global minima, without the need to minimize these complex cost functions and fall into the many local minima, or get stuck in zero gradient areas?

Finding optimal circles radius for a specific condition

let’s assume we have 3 points s={4,30,50}, Trying to draw a circle from each point to achieve the goal that every circle will touch the next one and the first circle is twice the size of the last one : so in the first point the circle should have a radius of 12 and the second one a radius of 14 and the last one 6.

What kind of algorithm or approach that can solve this problem for n points?

Optimal solution for Weighted points problem

Problem: Given a set of 2d points N: {N1, N2, N3, …., Nn}, find a set of points X: {X1, X2, X3, …., Xk} such that the points in X are D distance apart and Sum( Weight(Xi) ) from i= 1 to k is maximized.

The greedy way to do it would be to sort the points by weight and exclude points which are inside a distance of D from the current point that is being processed. Is there a better way to do it?

Efficient algorithm for finding optimal sum from both arrays

I have two arrays(A,B) and a sum M. I need to find one number from each array that makes the sum M. If there is no two elements that form sum M, then nearest and less than M sum is the solution. See examples below. What is the efficient way to find the solution for this?

eg1:  A =[200,300,600,900] B =[1000,200,300,500] M = 900 Output : A(2), B(2) 600 from A and 300 from B sums 900.  eg1:  A =[200,300,600,1000] B =[1000,400,600] M = 1500 Output : A(3), B(1) 1000 from A and 400 from B sums 1400 which is near to the sum 1500. 

Is there an optimal font size?

For most website projects I’ve been involved with, the font size for the bulk text is usually 12px – 13px, but I’m wondering if this is a good size. I remember reading an article saying that font sizes on websites should be much bigger, around 17px for bulk text to match printed font sizes.

Is there an optimal font size. When is something too big/small for the average user?

Is there any pro/cons for small/medium/large font sizes?

I would like to get your experience with actual tests user reactions etc. It’s easy to this, this and that is too big or small, but I’ve learned that users sometime surprise and react differently from expert opinions.

Also the ability to change font sizes is a good discussion, but it’s not what’s asked for here. What I’m interested in knowing more about, is how users react to different font sizes, not how they should be able to change it.

Optimal probability in slotted-aloha

I understand that in slotted aloha, given that the backlog of each node is infinite, the probability a node is successful able to transmit in a slot is

P(success) = Np(1−p)^(N−1)  

which means that the throughput,

S = Np(1−p)^(N−1) packets/(unit Time). 

Hence to find the optimal probability is it correct to set

dS/dp = 0? 

This will give


This got me a bit confused as if N approaches big values, the probability will approach 1.