page566.html
来自「Data Structures And Algorithms With Obje」· HTML 代码 · 共 41 行
HTML
41 行
<HTML><HEAD><TITLE>Data Structures for Dijkstra's Algorithm</TITLE></HEAD><BODY bgcolor="#FFFFFF"> <a href="../index.html" target="_top"><img src="../icons/usins.gif" alt="Logo" align=right></a><b>Data Structures and Algorithms with Object-Oriented Design Patterns in Python</b><br><A NAME="tex2html7667" HREF="page567.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html7665" HREF="page564.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html7659" HREF="page565.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html7669" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H3><A NAME="SECTION0016412000000000000000">Data Structures for Dijkstra's Algorithm</A></H3><P>The implementation of Dijkstra's algorithm described belowuses the <tt>Entry</tt> class declared in Program <A HREF="page566.html#progalgorithmsg"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.Each <tt>Entry</tt> value has three instance attributes,<tt>known</tt>, <tt>distance</tt>, and <tt>predecessor</tt>,which correspond to the variables <IMG WIDTH=14 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline71551" SRC="img2347.gif" >, <IMG WIDTH=14 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline71553" SRC="img2348.gif" >, and <IMG WIDTH=16 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline71555" SRC="img2349.gif" >, respectively.<P><P><A NAME="52052"> </A><A NAME="progalgorithmsg"> </A> <IMG WIDTH=575 HEIGHT=164 ALIGN=BOTTOM ALT="program51956" SRC="img2369.gif" ><BR><STRONG>Program:</STRONG> <tt>Algorithms.Entry</tt> class <tt>__init__</tt> method.<BR><P><P>In each pass of its operation,Dijkstra's algorithm selects from the set of verticesfor which the shortest-path is not yet knownthe one with the smallest tentative distance.Therefore, we use a <em>priority queue</em>to represent this set of vertices.<P>The priority assigned to a vertex is its tentative distance.The class <tt>Association</tt> class introduced in Program <A HREF="page127.html#progassociationa"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>is used to associate a priority with a given vertex instance.<P><HR><A NAME="tex2html7667" HREF="page567.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html7665" HREF="page564.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html7659" HREF="page565.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html7669" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <P><ADDRESS><img src="../icons/bruno.gif" alt="Bruno" align=right><a href="../copyright.html">Copyright © 2003</a> by <a href="../signature.html">Bruno R. Preiss, P.Eng.</a> All rights reserved.</ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?