{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Data Structures & Alogs HW_Part_19

Data Structures & Alogs HW_Part_19 - 73 2 3 1 10 x...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
73 2 3 4 5 6 1 10 x 20 x 2 2 3 5 x 12 3 x 15 x 4 11 10 5 3 2-paths: 2 3 4 5 6 1 10 13 15 x 2 2 3 5 x 12 3 8 15 15 4 11 10 5 3 3-paths: 2 3 4 5 6 1 10 13 15 x 2 2 3 5 18 12 3 8 15 x 4 11 10 5 3 4-paths: 2 3 4 5 6 1 10 13 15 31 2 2 3 5 16 12 3 8 15 15 4 11 10 5 3 5-paths: 2 3 4 5 6 1 10 13 15 31 2 2 3 5 16 12 3 8 15 15 4 11 10 5 3 6-paths:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
74 Chap. 11 Graphs 2 3 4 5 6 1 10 13 12 6 2 2 3 5 16 12 3 8 15 15 4 11 10 5 3 11.16 The problem is that each entry of the array is set independently, forcing pro- cessing of the adjacency list repeatedly from the beginning. This illustrates the dangers involved in thoughtlessly using an inef fi cient access member to a data structure implementation. A better solution is to process the actual edges within the graph. In other words, for each vertex, visit its adjacency list. Set the shortest-paths array by setting the values associated with that edge. If the array is initialized with values of , then any vertices not connected by an edge will retain that value.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}