<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../../xslt/mathml.xsl"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:m="http://www.w3.org/1998/Math/MathML">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Graph Theory: Networking</title>
    <link rel="stylesheet" href="../../css/style_mozilla.css" type="text/css" media="screen"/>
  </head>
  <body>
    <div id="logobarleft">
      <a href="http://links.math.rpi.edu/">
        <img src="../../css/titlebar_left.gif" alt="Project Links Logo"/>
      </a>
    </div>
    <div id="logobarright">
      <img src="../../css/titlebar_right.jpg" alt="Artwork"/>
    </div>
    <div id="titlebar">Graph Theory: Networking</div>
    <div id="breadcrumbbar">
			Home &gt; Graph Theory: Networking
					&gt; Foundations
					&gt; Definitions</div>
    <div id="sidebar">
      <div class="toolmenu1">
        <a href="banana.html" class="toolmenu1">Crib Sheet</a>
      </div>
      <br/>
      <div class="toolmenu2">
        <a href="banana.html" class="toolmenu2">Library</a>
      </div>
      <br/>
      <div class="toolmenu3">
        <a href="banana.html" class="toolmenu3">Help</a>
      </div>
      <br/>
      <div class="toolmenu4">
        <a href="banana.html" class="toolmenu4">Map</a>
      </div>
      <br/>
      <div class="toolmenu5">
        <a href="problemlist.xml" class="toolmenu5">Problem List</a>
      </div>
      <br/>
      <div class="toolmenu5">
        <a href="../index.html" class="toolmenu5">Module Home</a>
      </div>
      <br/>
      <div class="toolmenu6">
        <a href="http://links.math.rpi.edu/" class="toolmenu6">Links Home</a>
      </div>
      <br/>
      <br/>
      <div class="toc_topic">
        <a class="toc_link" href="page1.xml">Introduction</a>
      </div>
      <div class="toc_topic">
        <a class="toc_link" href="page2.xml">Objectives</a>
      </div>
      <div class="toc_topic">
        <a class="toc_link" href="page3.xml">Prerequisites</a>
      </div>
      <div class="toc_topic">
        <a class="toc_link" href="">Foundations</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page4.xml">Directed Graphs</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page6.xml">Definitions</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page9.xml">Shortest Paths</a>
      </div>
      <div class="toc_topic">
        <a class="toc_link" href="">Shortest-Path Algorithms</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page11.xml">Problem Variations</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page13.xml">Dijkstra's Algorithm</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page16.xml">Bellman-Ford Algorithm</a>
      </div>
      <div class="toc_topic">
        <a class="toc_link" href="">Routing</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page19.xml">Overview</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page21.xml">Designing A Routing Protocol</a>
      </div>
      <div class="toc_topic">
        <a class="toc_link" href="">Telephone Networks</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page23.xml">Overview</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page25.xml">Routing Strategies</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page26.xml">Costs</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page27.xml">DNHR</a>
      </div>
      <div class="toc_topic">
        <a class="toc_link" href="">The Internet</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page29.xml">Overview</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page30.xml">Distance-Vector Routing</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page33.xml">Link-State Routing</a>
      </div>
      <div class="toc_subtopic">
        <a class="toc_link" href="page37.xml">What's Next?</a>
      </div>
    </div>
    <div id="sectionbar">
      <div id="spacerright" class="spacerright">-</div>
      <div>
        <a href="page6.xml" class="sections">concepts</a>
      </div>
      <div>
        <a href="" class="sectionsgrayed">discover</a>
      </div>
      <div>
        <a href="page7.xml" class="sectionshighlighted">apply</a>
      </div>
      <div>
        <a href="page8.xml" class="sections">collaborate</a>
      </div>
      <div>
        <a href="" class="sectionsgrayed">practice</a>
      </div>
      <div id="spacerleft" class="spacerleft">-</div>
    </div>
    <div id="content"><h1>Definitions</h1>
				<h2>Applications: Representing a Graph in Computer Memory</h2>
				<p>
				Representing any graph, directed or undirected, in computer memory is
				accomplished with the use of an array of linked lists or an adjacency
				matrix.
				</p>
				<p>
				Let the vertices of a graph <m:math><m:mi>G</m:mi></m:math> be 
				<m:math>
					<m:msub>
						<m:mi>v</m:mi>
						<m:mn>0</m:mn>
					</m:msub>
					<m:mo>,</m:mo>
					<m:msub>
						<m:mi>v</m:mi>
						<m:mn>1</m:mn>
					</m:msub>
					<m:mo>,</m:mo>
					<m:mo>…</m:mo>
					<m:mo>,</m:mo>
					<m:msub>
						<m:mi>v</m:mi>
						<m:mrow>
							<m:mi>p</m:mi>
							<m:mo>-</m:mo>
							<m:mn>1</m:mn>
						</m:mrow>
					</m:msub>
				</m:math>.
				</p>
				
				<p>
				The <i>linked-list representation</i> of
				<m:math><m:mi>G</m:mi></m:math>
				is given by an array
				<m:math><m:mi>L</m:mi><m:mo>[</m:mo><m:mo>]</m:mo></m:math>
				of linked lists, where
				<m:math><m:mi>L</m:mi><m:mo>[</m:mo><m:mi>i</m:mi><m:mo>]</m:mo></m:math>
				is a linked list of vertices
				<m:math>
					<m:msub>
						<m:mi>u</m:mi>
						<m:mi>j</m:mi>
					</m:msub>
				</m:math>
				for which
				<m:math>
					<m:mfenced>
						<m:msub>
							<m:mi>v</m:mi>
							<m:mi>i</m:mi>
						</m:msub>
						<m:msub>
							<m:mi>u</m:mi>
							<m:mi>j</m:mi>
						</m:msub>
					</m:mfenced>
				</m:math>
				is an edge of
				<m:math><m:mi>G</m:mi></m:math>.
				</p>
				
				<div class="box">
					<b><i>Example</i></b>
					
					<div class="figure" align="center"><a name=""/><img src="../graphics/digraph2.gif"/><br/><b><i>Figure 3</i></b><br/><br/></div>
					<p>
					Below is the linked-list representation of the above graph.
					</p>
					<div class="figure" align="center"><a name=""/><img src="../graphics/linkedlist.gif"/><br/><b><i>Figure 4</i></b><br/><br/></div>
					
					
				</div>
				
				
				<p>
				The <i>adjacency matrix</i>
				<m:math>
					<m:mi>A</m:mi>
					<m:mo>=</m:mo>
					<m:mi>A</m:mi>
					<m:mo>⁡</m:mo>
					<m:mfenced>
						<m:mi>G</m:mi>
					</m:mfenced>
					<m:mo>=</m:mo>
					<m:mfenced close="]" open="[">
						<m:msub>
							<m:mi>a</m:mi>
							<m:mrow>
								<m:mi>i</m:mi>
								<m:mo>,</m:mo>
								<m:mi>j</m:mi>
							</m:mrow>
						</m:msub>
					</m:mfenced>
				</m:math>
				of
				<m:math><m:mi>G</m:mi></m:math>
				is the square matrix of order <m:math><m:mi>p</m:mi></m:math>, where
				<m:math>
					<m:msub>
						<m:mi>a</m:mi>
						<m:mrow>
							<m:mi>i</m:mi>
							<m:mo>,</m:mo>
							<m:mi>j</m:mi>
						</m:mrow>
					</m:msub>
					<m:mo>=</m:mo>
					<m:mn>1</m:mn>
				</m:math>
				if
				<m:math>
					<m:msub>
						<m:mi>v</m:mi>
						<m:mi>i</m:mi> 
					</m:msub>
				</m:math>
				is adjacent to
				<m:math>
					<m:msub>
						<m:mi>v</m:mi>
						<m:mi>j</m:mi>
					</m:msub>
				</m:math>
				otherwise.
				</p>
				
				<h2>Example</h2>
				<table border="1"><tr><td/><td><b>0</b></td><td><b>1</b></td><td><b>2</b></td><td><b>3</b></td><td><b>4</b></td></tr><tr><td><b>0</b></td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td><b>1</b></td><td>0</td><td>0</td><td>1</td><td>1</td><td>0</td></tr><tr><td><b>2</b></td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td><b>3</b></td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td><b>4</b></td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td></tr></table>
				
				<p>
				This is the 5x5 adjacency matrix <m:math><m:mi>A</m:mi></m:math> for the graph of the
				previous example.  The row and column indices (0 through 4) are
				<b>highlighted</b>.  The entry
				<m:math>
					<m:msub>
						<m:mi>A</m:mi>
						<m:mrow>
							<m:mn>3</m:mn>
							<m:mo>,</m:mo>
							<m:mn>2</m:mn>
						</m:mrow>
					</m:msub>
				</m:math>
				also is <b>highlighted</b>
				(for no reason other than to demonstrate the notation).
				</p>
			</div>
    <div id="nav">
      <a href="page6.xml" class="nav">back</a>
      <a href="page8.xml" class="nav">next</a>
    </div>
    <div class="copyright">
			Copyright 1999
			Rensselaer Polytechnic Institute. All Rights Reserved.
		</div>
  </body>
</html>
