21.11.2014 Views

CHAPTER 25 Weighted Graphs and Applications Objectives • To ...

CHAPTER 25 Weighted Graphs and Applications Objectives • To ...

CHAPTER 25 Weighted Graphs and Applications Objectives • To ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2097 (edges[2][2]). <strong>To</strong> create a <strong>Weighted</strong>Graph, you have to obtain a vector of <strong>Weighted</strong>Edge<br />

(lines 41–44).<br />

Line 52 invokes the print<strong>Weighted</strong>Edges() function on graph1 to display all edges in graph1.<br />

The program creates a <strong>Weighted</strong>Graph graph2 for the graph in Figure <strong>25</strong>.3 in lines 55–71. Line 75<br />

invokes the print<strong>Weighted</strong>Edges() function on graph2 to display all edges in graph2.<br />

Check point<br />

<strong>25</strong>.3 What is the output of the following code?<br />

vector list;<br />

list.push_back(<strong>Weighted</strong>Edge(1, 2, 3.5));<br />

list.push_back(<strong>Weighted</strong>Edge(1, 6, 6.5));<br />

list.push_back(<strong>Weighted</strong>Edge(1, 7, 1.5));<br />

cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!