Assume that there are two graphs like this:
We aim to find the matching correspondences between the two graph.And now we use a method to calculate the similarity of two nodes between the two graphs.
w(A,1) means the similarity of the node A from the left graph between the node 1 from the right graph. Then we can have table like this:
Our target is to calculate the maximum weight matching of all this nodes. And we can use the algorithm Kuhn-Munkras to solve this problem.
But now the question is that is if we add the similarity between edges from the two graphs,how can we calulate the maximum weight matching. It means that the table become this:
AA means the node A, and AB means the edge from A to B. The constraints are that if the final result is that node A matches node 1,the edge AB must matches 12 or 13.So can we use a algorithm like Kuhn-Munkras to solve this problem? If not , how can we find the the maximum weight matching in polynomial time?
Suppose we want to know if two graphs are isomorphic, e.g. the two in your example.
In the first graph we have edges AC and CB, while in the second graph we have edges 13 and 32.
We can set the weight matrix such that there is a high reward for mapping any edge in the first to an edge in the second.
i.e. AC->13 and AC->32 and CB->13 and CB->32 will all have weight 1, while all other matchings have weight zero.
There is an isomorphism between the graphs if and only if there is a maximum weight matching with weight equal to the number of edges.
Therefore your problem is at least as hard as graph isomorphism so it is unlikely that the Kuhn algorithm can be efficiently extended to this case.
Related
I've been reading some papers on multicut algorithms for segmenting graph structures. I'm specifically interested in this work which proposes an algorithm to solve an extension of the multicut problem:
https://www.cv-foundation.org/openaccess/content_iccv_2015/papers/Keuper_Efficient_Decomposition_of_ICCV_2015_paper.pdf
Regarding the edge costs, it says:
...for any pair
of nodes, a real-valued cost (reward) to all decompositions
for which these nodes are in distinct components
Fair enough. It further says that the solution to the multicut problem is a simple binary vector of length equal to the number of edges in the graph, in which a '1' indicates that the corresponding edge separates two vertices belonging to distinct graph components:
for every edge vw ∈ E ∪ F , y(v,w) = 1 if and only if v and w
are in distinct components of G.
But then the optimization problem is written as:
This doesn't seem to make sense. If the edge weights depict rewards for that edge connecting nodes in distinct components, shouldn't this be a maximization problem? And in either case, if all edge weights are positive, wouldn't that lead to a trivial solution where y is an all-zeros vector? The above expression is followed by some constraints in the paper, but I couldn't figure out how any of those prevent this outcome.
Furthermore, when it later tries to generate an initial solution using Greedy Additive Edge Contraction, it says:
Alg. 1 starts from the decomposition into
single nodes. In every iteration, a pair of neighboring components is joined for which the join decreases the objective
value maximally. If no join strictly decreases the objective
value, the algorithm terminates.
Again, if edge weights are rewards for keeping nodes separate, wouldn't joining any two nodes reduce the reward? And even if I assume for a second that edge weights are penalties for keeping nodes separate, wouldn't this method simply lump all the nodes into a single component?
The only way I see where this would work is if the edge weights are a balanced combination of positive and negative values, but I'm pretty sure I'm missing something because this constraint isn't mentioned anywhere in literature.
Just citing this multicut lecture
Minimum Multicut. The input consists of a weighted, undirected graph G
= (V,E) with a non-negative weight c_k for every edge in E, and a set of terminal pairs {(s1,t1);(s2,t2)...(sk,tk)}. A multicut is a set of
edges whose removal disconnects each of the terminal pairs.
I think from this definition it is clear that the multicut problem is a minimization problem for the accumulated weight which is defined by the selection of edges to cut. Maximizing the weight would of course be trivial (removing all edges). No?
Better late than never, here's the answer:
The weights c_e for cutting the edge e are not restricted to be positive as defined in Definition 1. In fact, Equation (7) specifies that they are log-ratios of two complementary probabilities. That means if the estimated probability for edge e being cut is greater than 0.5, then c_e will be negative. If it's smaller, then c_e will be positive.
While the trivial "all edges cut" solution is still feasible, it is quite unlikely that it is also optimal in any "non-toy" instance where you will have edges that are more likely to be cut while others are more likely to remain.
I have a weighted graph, and I want to compute a new weighting function for the graph, such that the edge weights are distinct, and every MST in the new graph corresponds to an MST in the old graph.
I can't find a feasible algorithm. I doubled all the weights, but that won't make them distinct. I also tried doubling the weights and adding different constants to edges with the same weights, but that doesn't feel right, either.
The new graph will have only 1 MST, since all edges are distinct.
Very simple: we multiply all weights by a factor K large enough to ensure that our small changes cannot affect the validity of an MST. I'll go overboard on this one:
K = max(<sum of all graph weights>,
<quantity of edges>)
+ 1
Number the N edges in any order, 0 through N-1. To each edge weight, add the edge number. It's trivial to show that
the edge weights are now unique (new difference between different weights is larger than the changes);
any MST in the new graph maps directly to a corresponding MST in the
old one (each new path sum is K times the old one, plus a quantity smaller than K -- the comparison (less or greater than) on any two paths cannot be affected).
Yes, this is overkill: you can restrict the value of K quite a bit. However, making it that large reduces the correctness proofs to lemmas a junior-high algebra student can follow.
We definitely cannot guarantee that all of the MSTs in the old graph are MSTs in the new graph; a counterexample is the complete graph on three vertices where all edges have equal weights. So I assume that you do not require the construction to give all MSTs, as that is not possible in the general case.
Can we always make it so that the new graph's MSTs are a subset of the old graph's? This would be easy if we could construct a graph without a MST. Of course, that doesn't make any sense and is impossible, since all graphs have at least one MST. Is it possible to change edge weights so that only one of the old graph's MSTs is an MST for the new graph? I propose that this is possible in general.
Determine some MST of the old graph.
Construct a new graph with the same edges and vertices, but with weights assigned as follows:
if the edge in the new graph belongs to the MST determined in step 1, give it a unique weight between 1 and n, the number of edges in the graph.
otherwise, give the edge in the new graph a unique weight greater than or equal to n^2, the square of the number of edges in the graph.
Without proof, it seems like this should guarantee that only the nominated MST from the old graph is an MST of the new graph, and therefore every MST in the new graph (there is just the one) is an MST in the old graph.
Now, one could ask whether we can do the deed with additional restrictions:
Can you do it if you only want to change the values of edges that are not unique in the old graph?
Can you do it if you want to keep relative weights the same for edges which were unique in the old graph?
One could even pose optimization problems:
What is the minimum number of edge weights that must be changed to guarantee it?
What is the weighting with minimum distance (according to some metric) from the old weighting that guarantees it?
What is the weighting that minimizes the average change while also guaranteeing it?
I am hesitant to attempt these, what I believe to be much more difficult, problems.
In Singapore, this year's (2016) NOI (National Olympiad in Informatics) included the following problem "ROCKCLIMBING" (I was unable to solve it during the contest.) :
Abridged Problem Statement
Given a DAG with N <= 500 vertices, find the maximum number of vertices in a subset of the original vertices such that there is no path from 1 vertex in the set to another vertex in the same set, directly or indirectly.
Solution
The solution was to use transitive closure algorithm, and then to form a bipartite graph by duplicating each vertex i to form i' such that if vertex j can be reached from vertex i directly or indirectly in the original graph, then there is a directed edge from i to j' in the new graph.
However, during the solution presentation, the presenters did not explain how or why N - MCBM (MCBM being the Maximum Cardinality Bipartite Matching) of the new bipartite graph is also the maximum size of the set of vertices that cannot reach each other directly or indirectly in the original DAG.
I looked up other problems related to DAGs and bipartite graphs, such as the Minimum Path Cover problem on DAGs, but I could not find anything that explains this.
Does anyone know a way in which to prove this equality?
The problem statement can be found here: ROCKCLIMBING
Thank you in advance.
There are two things going on here:
A set is independent if and only if its complement is a vertex cover (see wikipedia). This means that the size of a max independent set is equal to the size of a minimum vertex cover.
Konig's theorem proves that
In any bipartite graph, the number of edges in a maximum matching equals the number of vertices in a minimum vertex cover.
Therefore to find the size of the max independent set we first compute the size MCBM of the max matching, and then compute its complement which equals N-MCBM.
An alternative viewpoint is as follows:
If we use A<B to mean we can climb from A to B, we have defined a partially ordered set
There is a result called Dilworth's theorem that says the maximum number of incomparable elements is equal to the minimum number of chains
The proof shows how to construct the minimum number of chains by constructing a maximum matching in your bipartite graph.
Full question: Argue that if all edge weights of a graph are positive, then any subset of edges that connects all vertices and has minimum total weight must be a tree. Give an example to show that the same conclusion does not follow if we allow some weights to be nonpositive.
My answer: Since the edges connects all vertices, it must be a tree. In a graph, you can remove one of the edges and still connect all the vertices. Also, negative edges can be allowed in a graph (e.g. Prim and Kruskal's algorithms).
Please let me know if there's a definite answer to this and explain to me how you got the conclusion. I'm a little bit lost with this question.
First off, a tree is a type of graph. So " In a graph, you can remove one of the edges and still connect all the vertices" isn't true. A tree is a graph without cycles - i.e., with only one path between any two nodes.
Negatives weights in general can exist in either a tree or a graph.
The way to approach this problem is to show that if you have a graph that connects all components, but is NOT a tree, then it is also not of minimum weight (i.e., there is some other graph that does the same thing, with a lower total weight.) This conclusion is only true if the graph contains only positive edges, so you should also provide a counterexample - a graph which is NOT a tree, which IS of minimum weight, and which IS fully connected.
With non-negative weights, adding an edge to traverse from one node to another always results in the weight increasing, so for minimum weight you always avoid that.
If you allow negative weights, adding an edge may result in reducing the weight. If you have a cycle with negative weight overall, minimum weight demands that you stay in that cycle infinitely (leading to infinitely negative weight for the path overall).
I have a grid based graph, where nodes and edges occupy cells. Edges can cross, but cannot travel on top of each other in the same direction.
Lets say I want to optimize the graph so that the distance covered by edges is minimized.
I am currently using A* search for each connection, but the algorithm is greedy and does not plan ahead. Consider the diagram below, where the order in which connections are made is changed (note also that there can be multiple shortest paths for any given edge, see green and
purple connections).
My intuition says this is NP-Complete and that an exhaustive search is necessary, which will be extremely expensive as the size of the graph grows. However, I have no way of showing this, and it is not quite the same as other graph embedding problems which usually concern minimization of crossing.
You didn't really describe your problem and your image is gone, but your problem sounds like the minimum T-join problem.
The minimum T-join problem is defined on a graph G. You're given a set T of even size, and you're trying to find a subgraph of the graph where the vertices of T have odd degree and the other vertices have even degree. You've got weights on the edges and you're trying to minimise the sum of the weights of edges in the subgraph.
Surprisingly, the minimum T-join problem can be solved in polynomial time thanks to a very close connection with the nonbipartite matching problem. Namely, if you find all-pairs shortest paths between vertices of T, the minimum T-join is attained by the minimum-weight perfect matching of vertices in T, where there's an edge between two vertices whose length is the length of the shortest path in G.
The minimum T-join will be a collection of paths. If two distinct paths, say a->b and c->d, use the same edge uv, then they can be replaced by a->u->c and b->v->d and reduce the cost of the T-join. So it won't use the same edge twice.