简体   繁体   English

具有锁定和未锁定边缘的无向图中的最小路径

[英]Minimum path in an undirected graph with locked and unlocked edges

Given an undirected graph with positive weights , there are 2 kinds of edges: locked edges and unlocked edges. 给定一个具有正权重的无向图,则有两种边缘:锁定边缘和未锁定边缘。 Determination if a given edge is either locked or unlocked edge takes O(1). 确定给定边缘是锁定边缘还是未锁定边缘需要O(1)。

  1. For given two vertices s , t and a positive number k = O(1), how can I find the shortest path between s and t which contains at most k locked edges? 对于给定的两个顶点st和一个正数k = O(1),我如何找到st之间最多包含k个锁定边的最短路径?

  2. For given two vertices s , t and a positive number k = O(1), how can I find the shortest path between s and t which contains exactly k locked edges? 对于给定的两个顶点st和一个正数k = O(1),我如何找到st之间最短路径,该路径包含恰好有 k个锁定边?

I'm not sure how can I run Dijkstra algorithm on this graph to find the shortest path between the given vertices, and how can I transform the undirected graph, into an directed one. 我不知道我怎么能在这个图运行Dijkstra算法找出给定顶点之间的最短路径,以及如何改造无向图,为导演之一。

You can solve both of your problems by taking k copies of the graph, say G_0, ..., G_k, and modifying each graph so that a locked edge vw in G_i turns into an edge from u in G_i to v in G_{i+1} and from v in G_i to u in G_{i+1}. 您可以通过制作k个图的副本(例如G_0,...,G_k)并修改每个图,以使G_i中的锁定边vw变为从G_i中的u到G_ {i中的v的边,来解决这两个问题。 +1},然后从G_i中的v到G_ {i + 1}中的u。 Then you can do single-source shortest paths from your root in G_0. 然后,您可以从G_0的根目录开始执行单源最短路径。 The second query is solved by reading off the distance to the target in G_k, while the first is solved by reading off the minimum distance in any G_i to the target. 第二个查询通过读取G_k中距目标的距离来解决,而第一个查询则通过读取G_k中距目标的最小距离来解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无向图的最小加权路径树 - Minimum Weighted Path Tree of an Undirected Graph 在有负边的无向图中找到最小权重生成树 - Find a minimum weight spanning tree in the undirected graph where there are negative edges 无向图:最小生成树,红色边缘越少越好 - Undirected Graph: Minimum Spanning Tree with few red edges as possible 循环无向图中最长的路径,具有递增的边权重 - Longest Path, with Ascending Edges Weights, in Cyclic Undirected Graph 使用邻接表的无向加权图上的最小成本路径 - Minimum cost path on a undirected weighted graph using an adjacency list 在无向图中打印循环的边 - Print edges of a cycle in an undirected graph 打印无向图的边缘(点) - Print the edges (points) of undirected graph 无向图中的访问边,顶点 - Visiting edges, vertices in an undirected graph 给定一组边和一个无向图,我如何选择最好的边添加到图中以最小化最短路径? - Given a set of edges and an undirected graph, how do I pick the best edge to add to graph to minimize the shortest path? 在具有相同数量的顶点和边NP-Complete的加权无向图中找到具有最大成本的简单路径的问题吗? - Is the problem of finding the simple path with maximum cost in a weighted undirected graph with the same number of vertex and edges NP-Complete?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM