I came across this problem - In an undirected graph every node and edge has a weight. All the weights are non-negative. Given a value S, Find the connected subgraph with minimum sum of edge weights such that its sum of node weights is at least S.
The most obvious solution is a brute force approach considering all possible subgraphs. But the time complexity is exponential. Is there any better algorithm for this? My intuition is that we can convert node weights to edge weights and then apply spanning tree algorithm. But I couldn't solve it clearly. How to solve this problem?
EDIT : Looks like I was not clear enough about the description of subgraph. The selected subgraph must be a single, connected component. I hope it's clear now.
I think this problem is NP-hard via a reduction from the Steiner tree problem. Given a graph G and a set of nodes S that need to be spanned, set the weight of all of the nodes in S to one and all the other nodes to 0. A subgraph with node weight at least |S| with minimum total edge cost must be a tree (if there are any cycles, deleting an edge from the cycle only decreases the cost) and must connect all of the nodes that need to be spanned. It's therefore a Steiner tree. Overall, this reduction can be computed in polynomial time, so your problem is NP-hard.
Related
Having an undirected graph with v vertices and e edges with each edges having a non-negative weight of at most w, the task is to find(if possible!) a subset of edges that connects all vertices with minimum cost. Also this graph has a root node which in the sub-graph should only be directly connected to exactly k other vertices(so it most have exactly k edges connected to it in the sub-graph). The algorithm should work in O(e⋅log(v)⋅log(w)) time.
So after some thinking I thought that we need to find a minimum spanning tree since it gives us the Minimum-cost subgraph which takes O(e.log(v)) time.However for insuring that the root node has exactly k edges in the resulting tree I couldn't come up with any working idea.
I think that maybe changing the weights of k edges that are connect to the root may enforce their selection,since in the Kruskal's algorithm we first sort the edges, if we pick exactly k edges that are already connected to the edge root in the graph and change their weights to some minimum amount then in the tree construction phase, chances are that this k edges make it to the MST. There are still problems here:
K edges should be picked so that it would be possible for them to make it to an MST.
The scenario at hand that I would like to solve is a maximization problem where each vertex in the connected un-directed graph has a value. However, each edge and vertex also has a cost.
Given a starting vertex and a cost budget, is there a recommended algorithm or approach to find the connected subgraph which maximizes the vertex value
(including the starting vertex) ?
This is NP-hard because you could use an algorithm for this to solve the Steiner tree problem in graphs by setting the value for each terminal to be 1, the cost for each vertex to be 0, and the cost for each edge to be 1. There is a Steiner tree with weight k if and only if your algorithm with a cost budget of k is able to capture the value from all the terminals.
It may help to investigate the literature for Steiner trees to get some ideas for approximate solution ideas.
Given a connected undirected graph, the problem of finding the spanning tree with the minimum max degree has been well-studied (M. F¨urer, B. Raghvachari, "Approximating the minimum degree spanning tree to within one from the optimal degree", ACM-SIAM Symposium on Discrete Algorithms (SODA), 1992). The problem is NP-hard and an approximation algorithm has been described in the reference.
I am interested in the following problem - given a connected undirected graph G = (V1,V2,E), find the spanning tree with the maximum min degree over all internal nodes (non-leaf nodes). Can someone please tell me if this problem has been studied; is it NP-hard or does there exist a polynomial-time algorithm for solving it? Also, the graph can be considered to be bipartite for convenience.
As noted in Evgeny Kluev's comment, the leaves of a (finite) tree have degree 1. (Else, cycles would exist and the structure would not be a tree.)
If instead you mean to find a spanning tree with a node of maximum degree, from among all possible spanning trees on a connected undirected graph G, then just form a spanning tree whose root R is a node M of G with maximal degree among all the nodes of G, and all neighbors of M are children of R.
It looks like exact cover by 3-sets can be reduced to this problem. Represent the 3-sets by vertices of degree 4, each with 3 edges connecting it to 3 nodes representing its elements in the original problem instance. The additional 4th edge connects all the "3-set" nodes to a single vertex V.
This graph is biparite - every edge is between a "3-set" node and an "element" node (or V). Now this graph has a spanning tree of max min degree = 4 if and only if the original problem has a solution.
Obviously there need to be enough of the 3-sets so that the node V doesn't lower the max min degree of the tree, but this limit doesn't change the NP-hardness of the problem.
I am working on a research problem involving logic circuits (which can be represented as DAGs). Each node in the DAG has a given weight, which can be negative. My objective is to find a connected subgraph such that the sum of the node weights is maximal.
The maximum weight connected subgraph problem given edge weights is NP-hard apparently, but what I am hoping is that the directed-acyclic nature and the fact that I am dealing with node weights rather than edge weights makes the problem somewhat easier. Can someone point me in the right direction of how to start attacking this problem?
Thanks
the problem you mentioned is NP-hard, see:
“Discovering regulatory and signaling circuits in molecular interaction networks”
by Trey Ideker, Owen Ozier, Benno Schwikowski, and Andrew F. Siegel,
Bioinformatics, Vol 18, p.233-240, 2002
and the supplementary information to this paper:
http://prosecco.ucsd.edu/ISMB2002/nph.pdf
First approach, Assign to each edge the inverse of the weight of the starting node, and apply a shortest path algorithm like Bellman-Ford. The Dijkstra's algorithm won't work as some edges can be negative.
Second approach, starting on each leaf node, add "tags" to each edge that keeps track of the ids of all the nodes involved, and the total weight. There is no need to mark the node, as each node is guaranteed to be visited only once for each chain starting on the leafs. For example, given the following Acyclic Directed graph (directed top to bottom) where each node weights 1:
A G
/ \ /
/ \ /
B C
| / \
D E F
\ /
H
The edge between A and B will be tagged {{D,B,A},3}, the edge between A and C will have two tags {{H,E,C,A},4} and {{H,F,C,A},4}.
After this pre-procesing, find the greatest weight path for each root node. The information is in the tags of their outbound edges.
You mentioned that connected that connected subgraph should be "maximal". For this greedily choose a vertex and grow it until you cannot grow. this assures maximality. However if you mean "maximum" then the problem might be NP_Complete. Also let me remind you that node weighted graphs are more general than edge weighted graphs. Every algorithm built for the former is applicable to later but vice-versa is not always true. This is very easy to see. Try out yourself.
What i understand the problem, i feel it is in P. If that is correct then the Hint for that is to use some special property for DAGs (which u shud know since u r researching and this seems a lecture notes problem). For general graphs, this is reducible to steiner trees so it is NP-Cmplete(infact also for planar graphs).
I think your problem is NP hard if the maximum weight connected subgraph problem given edge weights is NP hard. You can reduce the node weight problem to the edge weight problem.
1)Lets say that your nodes have weights wn1,wn2,wn3,....wnN; where N is # of nodes.
2)Lets also say that the edges can be represented by e1,e2,e3,...eE; E- # of edges.
The weight of the edge ei:nj->nk can be defined as F(wnj,wnk), the function being
arbitrary. For simplicity we can assume wei=wnj+wnk.
Now if we assume that all node weights are independent and non-identical, then we
can say the same about the edge weights. As a DAG with non-identical edge weights
is NP hard, your problem too is.
Having said that, I think you should proceed in the following way:
1)Look for similarity in node weights for your particular problem. If there are any,
try to look up the literature for similar problems.
2)If they are hard to find, I suggest you translate your node weight problem to edge
weight one, and see how the similarity in node weights translates to edge weights
problem and see what simplification can you apply to this problem, again from
literature.
I hope this helps.
For fun I'm learning about graph theory and I came across this problem. Given a set of vertices V, a set of edges E, and a weight for each edge in E, how can I efficiently construct a graph G such that:
G is connected (all vertices are connected via some path)
the sum of the weights of the edges is minimized
The edges in E are directed, when all edges in E are present there can be cycles.
See Minimum Spanning Tree algorithms.
ok... can i know what MrDatabase is after? SSSP algorithms (dijkstra, Bellman-Ford) are variation of MST, which ars just mentioned. Dijkstra does not solve negative weight cycle issue while Bellman-Ford does.
To add to ars's answer, if your graph contains edges with negative weight, then the problem becomes more difficult (and there may be no solution if you have a negative-weight cycle).
Read Bellman-Ford Algorithm. It supports negative weight cycles. Dijkstra's algorithm is more efficient but it doesn't support negative weight cycles.