📄 page535.html
字号:
<HTML><HEAD><TITLE>Edges</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="tex2html7320" HREF="page536.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html7318" HREF="page532.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html7312" HREF="page534.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html7322" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION0016220000000000000000">Edges</A></H2><P>An edge in a directed graph is an ordered pair of vertices;an edge in an undirected graph is a set of two vertices.Because of the similarity of these concepts,we use the same class for both--the context in which an edge is used determines whether it is directedor undirected.<P>Program <A HREF="page535.html#progedgea"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> defines the <tt>Edge</tt> class.The abstract <tt>Edge</tt> class extendsthe abstract <tt>Object</tt> classintroduced in Program <A HREF="page116.html#progobjecta"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.<P><P><A NAME="49954"> </A><A NAME="progedgea"> </A> <IMG WIDTH=575 HEIGHT=525 ALIGN=BOTTOM ALT="program49500" SRC="img2262.gif" ><BR><STRONG>Program:</STRONG> Abstract <tt>Edge</tt> class.<BR><P><P>An edge connects two vertices, <IMG WIDTH=14 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline71023" SRC="img2263.gif" > and <IMG WIDTH=13 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline70743" SRC="img2206.gif" >.The properties <tt>v0</tt> and <tt>v1</tt> return these vertices.The <tt>isDirected</tt> property returns <tt>True</tt> if the edge is directed.When an <tt>Edge</tt> is directed,it represents <IMG WIDTH=52 HEIGHT=15 ALIGN=MIDDLE ALT="tex2html_wrap_inline71027" SRC="img2264.gif" >.That is, <IMG WIDTH=13 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline70743" SRC="img2206.gif" > is the head and <IMG WIDTH=14 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline71023" SRC="img2263.gif" > is the tail.Alternatively, when an <tt>Edge</tt> is undirected,it represents <IMG WIDTH=51 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline71033" SRC="img2265.gif" >.<P>For every instance <tt>e</tt> of a classderived from the <tt>Edge</tt> classthe <tt>mateOf</tt> method satisfies the following identities:<P> <IMG WIDTH=173 HEIGHT=37 ALIGN=BOTTOM ALT="gather49536" SRC="img2266.gif" ><P>Therefore, if we know that a vertex <tt>v</tt> is one of the vertices of <tt>e</tt>,then we can find the other vertex by calling <tt>e.Mate(v)</tt>.<P><HR><A NAME="tex2html7320" HREF="page536.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html7318" HREF="page532.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html7312" HREF="page534.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html7322" 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -