Difficulties understanding, bipartite graphs - algorithm

I am looking back at some of my algorithms homework(exam soon haha), and I am having troubles understanding the solution to one of the questions.
The Question
Tutor Solution
I am having difficulties visualizing the solution, I understand that if you have an odd number of cycles than your graph cannot be bipartite. But as I stated, I don't understand the shortest path from s to u and v to s.

Let's say G is bipartite. Then the vertex set can be divided into V1 and V2 s.t. every edge of G includes a vertex from each set. Then the vertices of every path in G alternate between V1 and V2, so the parity of the length of every path between every pair of vertices is the same. I.e., if G is bipartite and v,w are two vertices of G, then the length of every path connecting v & w is either even or odd.
If there is an edge (u,v) connecting two vertices in the same layer then this is violated. The BFS path to v and u have the same length, so same parity, since v & u are in the same layer. The edge between v & u gives us a path longer by 1, so of a different parity. Contradiction.

The tutor's solution isn't as clear as it could be, since it talks about cycles, and the two paths don't necessarily form a cycle since they can share vertices. And the definition of bipartite graph is slightly wrong (or uses non-standard definitions of edges, cross-product etc. where the things aren't pairs but 2-element sets).
But instead of the definition as given, I'd just say that a graph is bipartite if the vertices can be coloured black or white, such that each edge goes between different-coloured vertices. (Equivalently you can simply say "the graph is 2-colourable").
From this definition, it follows that if there's an even length path between two vertices they must be the same colour, otherwise different colours. In the BFS on a bipartite graph, a vertex u is layer i has a path of length i from s to u, so all vertices in the same layer have the same colour. Thus there can be no edge between two vertices in the same layer.

Related

Proof of having k edge-disjoint paths there and back

I have been trying to prove this for a decent amount of time, but nothing is coming to my mind. Anybody have some tips? I'd be happy to see an explanation.
I also found this question on StackOverflow, that says this:
If the direct u->v traffic doesn't knock out any links in v->u, then
the v->u problem is equivalent of finding the maximum flow from v->u
as if the u->v flow doesn't happen.
He describes how it can be solved, but still there is no answer to the question that the author asked.
So, the problem is:
Given a directed graph, at each vertex the number of incoming and outgoing edges is the same. Let there be k edge-disjoint paths from b to a in this graph.
How can I prove that it also contains k edge-disjoint paths from a to b?
Thanks in advance!
We can try to argue about the general case where the graph is a multi-graph (i.e. can have multi-edges and loops).
Note: Following the convention that two copies of an edge count towards in and degree twice. And a loop count towards both in and out degree once. Also assuming when you say paths, you mean simple paths.
Using induction on the number of vertices in the graph G.
Base case: G has only vertices a and b.
Now as there are k edge-disjoint paths from a to b, all of them are simply k copies of the edge a->b. Thus to have in and out degrees same for both vertices there have to be k copies of b->a, and thus the claim holds.
Induction G has n >=1 vertices apart from a and b.
Let the nth vertex be u. Let in-degree of u, same as its out-degree be d. Let the d vertices with edges "going into" u be s1,s2,..,sd and similarly the d vertices with edges going out from u be t1,t2,..,td (note all these vertices may not be unique). Just pair these vertices up. Say si with ti (1<=i<=d). Now just "short-circuit" the vertex u, i.e. rather than having the edge si->u->ti, just have si->ti. Let the new graph be G'. It is trivial to see in and out degree of vertices are still the same in G' (as it was in G). And it is not hard to argue that the new graph still has k disjoint paths from a to b. Additionally G' has one less vertex. So apply inductive hypothesis, and claim holds for G'. Lastly not hard to check again, un-short circuiting u still keeps the claim intact for G.

Algorithm for dividing graph into edge pairs

I've received a task to find an algorithm which divides a graph G(V,E) into pairs of neighboring edges (colors the graph, such that every pair of neighboring edges has the same color).
I've tried to tackle this problem by drawing out some random graphs and came to a few conclusions:
If a vertex is connected to 2(4,6,8...) vertices of degree 1, these make a pair of edges.
If a vertex of degree 1 is directly connected to a cycle, it doesn't matter which edge of the cycle is paired with the lone edge.
However, I couldn't come up with any other conclusions, so I tried a different approach. I thought about using DFS, finding articulation points and dividing graph into subgraphs with an even number of edges, because those should be dividable by this rule as well, and so on until I end up with only subgraphs of |E(G')| = 2.
Another thing I've come up with is to create a graph G', where E(G) = V(G') and V(G) = E(G'). That way I could get a graph, where I could remove pairs of vertices (former edges) either via DFS or always starting with leaf vertices along with their adjacent vertices.
The last technique is most appealing to me, but it seems to be the slowest one. Any feedback or tips on which of these methods would be the best is much appreciated.
EDIT: In other words, imagine the graph as a layout of a town. Vertices being crossroads, edges being the roads. We want to decorate (sweep, color) each road exactly once, but we can only decorate two connected roads at the same time. I hope this helps for clarification.
For example, having graph G with E={ab,bd,cd,ac,ae,be,bf,fd}, one of possible pair combinations is P={{ab,bf},{ac,cd},{ae,eb},{bd,df}}.
One approach is to construct a new graph G where:
A vertex in G corresponds to an edge in the original graph
An edge in G connects vertices a and b in G where a and b represent edges in the original graph that meet at a vertex in the original graph
Then, if I have understood the original problem correctly, the objective for G is to find the maximum matching, which can be done, for example, with the Blossom algorithm.

Minimum sum of distances from sensor nodes to all others

Is there a way to compute (accurate or hevristics) this problem on medium sized (up to 1000 nodes) weighted graph?
Place n (for example 5) sensors in nodes of the graph in such way that the sum of distances from every other node to the closest sensor will be minimal.
I'll show that this problem is NP-hard by reduction from Vertex Cover. This applies even if the graph is unweighted (you don't say whether it's weighted or not).
Given an unweighted graph G = (V, E) and an integer k, the question asked by Vertex Cover is "Does there exist a set of at most k vertices such that every edge has at least one endpoint in this set?" We will build a new graph G' = (V', E), which is the same as G except that all isolated vertices have been discarded, solve your problem on G', and then use it to answer the original question about Vertex Cover.
Suppose there does exist such a set S of k vertices. If we consider this set S to be the locations to put sensors in your problem, then every vertex in S has a distance of 0, and every other vertex is at a distance of exactly 1 away from a vertex that is in S (because if there was some vertex u for which this wasn't true, it would mean that none of u's neighbours are in S, so for each such neighbour u, the edge uv is not covered by the vertex cover, which would be a contradiction.)
This type of problem is called graph clustering. One of the popular methods to solve it is the Markov Cluster (MCL) Algorithm. A web search should provide some implementation examples. However it does not generally provide the optimal solution.

Minimum Vertex Cover On A Bipartite Graph

Let’s say you have a bipartite graph G = (V, U, E)
v1 is connected to u1, u2, and u3
v2 is connected to u2 and u3
v3 is connected to u3.
By looking at the graph, I know that the minimum vertex covers are {v1, v2, u3} and {v1, u2, u3}, but I’m not sure how to use the bipartite matching/vertex cover algorithm to find this out. Here
and Here
When I perform algorithm by hand, the output is just the trivial minimum vertex cover, all of V. Am I doing something wrong?
Edit:
The maximum matching for the graph are the edges (v1, u1), (v2, u2), and (v3, u3). Given the maximum matching, the next step is to start at an unsaturated vertex (a vertex that is not one of the endpoints of a matched edge)
But in this case all the vertices are saturated, so I don't know how to proceed.
Konig's theorem has two directions. The easy direction, corresponding to weak linear programming duality, is that the vertex cover is at least as large as the matching. This is because, in every vertex cover, each matching edge has at least one of its endpoints present.
The hard direction of Konig's theorem, corresponding to strong LP duality, is that there exists a vertex cover where at most (i.e., exactly) one endpoint of each matching edge is present. The thrust of Wikipedia's current proof is to use the matching to construct a vertex cover greedily, showing that, if this algorithm gets stuck, then the allegedly maximum matching has an augmenting path (a contradiction). Every edge is incident to a matched vertex, so the unmatched vertices can be excluded from the cover. Their neighbors in turn must be included. Their neighbors' neighbors can be excluded, etc.
You've noticed that this process sometimes fails to determine the status of each vertex. For this case, the Wikipedia editors write "If there is no such vertex, but there remain vertices not included in any previously-defined set Sk, arbitrarily choose one of these and let S2j+1 consist of that single vertex." One way to justify this step is as follows. Letting u be the chosen vertex and v be u's mate, we're pretending as though v's mate was not u but a newly created vertex u'. Then u is unmatched, so we reseed the algorithm by excluding u and cover the newly created edge u' -- v when we subsequently include v.

Bounding the number of edges between star graphs such that graph is planar

I have a graph G which consists only of star graphs. A star graph consists of one central node having edges to every other node in it. Let H1, H2,…,Hn be different star graphs of different sizes which are present in G. We call the set of all nodes which are centres in any star graph R.
Now suppose these star graphs are building edges to other star graphs such that no edge is incident between any nodes in R. Then, how many edges exist at maximum between the nodes in R and the nodes which are not in R, if the graph should remain planar?
I want the upper bound on the number of such edges. One upper bound that I have in mind is: consider them as bipartite planar graph where R is one set of vertices and rest of the vertices form another set A. We are interested in edges between these sets (R and A). Since it is planar bipartite, the number of such edges is bounded by twice the number of nodes in G.
What I feel is that is there a better bound, maybe twice the nodes in A plus the number of nodes in R.
In case you can disprove my intuition, then that would also be good. Hopefully some of you can come up with a good bound along with some relevant arguments.
That's the best you can do. Take any planar graph G and construct its face-vertex incidence graph H, whose faces all have 4 edges. Let R be the set of faces of G and construct stars any which way using edges in H. This achieves the bound for bipartite planar graphs.

Resources