Given an unweighted graph how do I find a spanning tree with 1. Maximum number of leaves 2 minimum number of leaves - algorithm

write an algorithm to find a spanning tree that has the maximum number of leaves.
Write an algorithm to find a spanning tree with minimum number of nodes.
I am yet not able to come up with a solution for the following questions.
For the first part what I thought is to find the vertex with the highest degree and place it in the second last level such that the last level gets the maximum number of leaves.

Finding a spanning tree of a graph with maximum number of leaves is an NP-Complete problem. There is a reduction from the Dominating Set Problem which is NP-Complete.
Finding a spanning tree of a graph with minimum number of leaves is also an NP-Complete problem. Suppose if the graph has a Hamiltonian path then the graph has a spanning tree with just two leaves. Thus finding a spanning tree of a graph with minimum number of leaves is equivalent to finding whether a graph has a Hamiltonian path or not.
So for both the problems you need to develop approximation algorithms.

Related

Spanning Trees with minimum number of leaves

So my problem is the following:
I have an undirected (complete) weighted graph G=(V,E), and I would like to generate all the possible spanning trees with minimum number of leaves, i.e. with minimum number of vertices of degree 1. Let's call this kind of trees MIN_LEAF.
Possibly, I would like to directly generate, among all trees with minimum number of leaves, the one which has also the minimum total weight (please note that this is not necessarily a minimum spanning tree).
Is the problem of deciding if a tree T is a MIN_LEAF for a given graph G NP-complete?
If so, I wonder if some kind of heuristic algorithm exists (greedy or local search) which can at least give an approximate solution for this problem.
Thanks in advance.
The first problem you described - finding a spanning tree with the fewest number of leaves possible - is NP-hard. You can see this by reducing the Hamiltonian path problem to this problem: notice that a Hamiltonian path is a spanning tree of a graph and only has two leaf nodes, and that any spanning tree of a graph with exactly two leaf nodes must be a Hamiltonian path. That means that the NP-hard problem of determining whether a Hamiltonian path exists in a graph can be solved by finding the minimum-leaf spanning tree of the graph: the path exists if and only if the minimum-leaf spanning tree has exactly two leaves. The second problem you've described contains that first problem as a special case and therefore is going to also be NP-hard.
A quick Google search turned up the paper "On finding spanning trees with few leaves", which seems like it might be a good starting point for approximation algorithms (they have a 2-approximation for arbitrary graphs) and further reading on the subject.

Widest path algorithm proof of correctness

How do you prove that that the maximum spanning tree of an undirected graph will contain the path that is the widest path between any two vertices A and B in the graph?
I have tried thinking about the proof for Kruskal's algorithm with an edit so it produces the maximum spanning tree but I do not see why the maximal spanning tree must contain the edges in the widest path especially if there are multiple widest paths.
Proofs about optimality are often by contradiction. Here you'd set yourself up to find one by saying
Suppose there are vertices A and B with a widest path between them containing at least one edge not in any maximum spanning tree of the graph.
Now you must show that the existence such an edge leads to the desired contradiction. One clear path would be to show that this edge can be used to construct a new spanning tree of weight greater than any of the graph's maximum spanning trees. Therefore they weren't maximum after all.
The existence of a contradiction shows that the hypothetical widest path from A to B doesn't exist. Therefore the proof is at hand.

Maximum edge-weighted subtree T' constrained by number of max k edges, starting with the same root as T

I got an edge-weighted undirected acyclic graph and I have to find a max subtree containing the same root with limited number of edges. I know that it's easy to find a max path and it can be done with dfs, but this problem is very similar to K-minimum spanning tree, which is NP-hard and I couldn't find any implementation suitable for it. I'm looking for a simple, approximate solution to solve this problem.

Finding spanning tree with maximum minimum degree

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.

Undirected graph into Minimum cost union of paths

I have to create a solution for a weighted undirected graph, passing through all the nodes, with a total minimum cost. Several paths, with no defined starting nodes, should end up and meet at one intersecting node. The number of the paths, and the number of the nodes included in a path are not pre-determined. The nodes can be passed more than once.
What kind of problem am I dealing with, possible algorithms as solution?
I suppose it should be a variation of a Minimum spanning tree (meaning using the intersection node as a starting point for the paths in stead of ending point)
It's called Minimum Cost Hamiltonian Circuit problem.
Here you can read more about it.
It is a tree you are looking for and the problem is Minimum Spanning Tree-- MST: building a tree that spans all the nodes in graph and the cost of edges on the tree is minimum possible. It is a polynomial problem. Prim and Kruskal each have well-known algorithms for the solution.
See http://en.wikipedia.org/wiki/Kruskal's_algorithm for Kruskal's algorithm.
Note: the problem is NP-complete when the tree is supposed to span a given proper subset of nodes instead of all nodes in the graph. This time it is known as the Steiner Minimal Tree problem.

Resources