简体   繁体   中英

find shortest path between 2 vertices using BFS algorithm

I have this question for homework:

prove/disprove:

A. Given an unintentional bound graph G (V, E) and a minimum spanning tree for this graph, and 2 vertices u, v, the shortest path between u and v in graph G can be found by performing BFS on the tree T.

B. Given a directed graph G (V, E) with weights and vertex s. The number of arcs in the shortest distance tree of this graph from the origin of s is the | V | -1.

I think that's true but can't prove it.

Can someone help me?

A. Not true, the minimum spanning tree does not contain all the shortest paths. example: 在此处输入图像描述

The MST is the black edges (weight=1) the red edge (weight=2) is the shortest path between its nodes.

B. True, suppose you have a shortest paths graph with |V| edges, than there is a node v with at least two path from s (let v be the closest node to s with that property), in that case you can remove one of the incoming edges of v without changing the weights of the paths to all the nodes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM