Prims Algorithm

버전 1.0.0.0 (1.59 KB) 작성자: Vikramaditya Kundur
Minimal spanning tree.
다운로드 수: 8.6K
업데이트 날짜: 2005/9/30

라이선스 보기

In the mathematical field of graph theory, a spanning tree of a connected, undirected graph is a tree which includes every vertex of that graph. More generally, a spanning forest of an arbitrary undirected graph is a forest which includes every vertex of the graph. Spanning forests always exist, and can always be constructed so as to have exactly one tree for each connected component. In certain fields of graph theory, involving weighted graphs, it is often useful to find a minimal spanning tree.

Prim's algorithm builds a tree while having the graph connected at all times.

Prim's algorithm maintains two lists, EV which is the vertices already in the tree, and E, the list of edges that makes up the spanning tree. In determining current edges for the tree, we look for a node that's in EV, and on that isn't, such that its path is minimum.
EV = { 0 }

E = { }

while( E has < n-1 edges ) {

find (u,v) with least cost, such that
u is in EV and v isn't in EV

if no such edge exists, break

add v to EV

add (u,v) to E
}
On termination, if the graph is connected, EV will contain all the nodes in the graph, and E will contain the set edges comprising the minimum spanning tree.

인용 양식

Vikramaditya Kundur (2024). Prims Algorithm (https://www.mathworks.com/matlabcentral/fileexchange/8569-prims-algorithm), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R12.1
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Construction에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0

Found an error. Need to update with a new file.