Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Should the Iterator that Graph.findPath returns be over a “list” of just vertices, or over an alternating “list” of vertex / edge (starting and ending with a vertex), as the textbook discusses paths?

0
Posted

Should the Iterator that Graph.findPath returns be over a “list” of just vertices, or over an alternating “list” of vertex / edge (starting and ending with a vertex), as the textbook discusses paths?

0

Yes indeed, a path can be expressed in either of those two ways: • A list of vertices. (This includes the guarantee that every pair of adjacent vertices in the list really do have an edge between them.) • An alternating list of vertex / edge, starting and ending with a vertex. For the project, the first way is to be used: a list of vertices. Graph’s addEdge does not return an edge name or label. So the Labyrinth application (or any other application) would not understand any edge label that Graph might return. For this type of application, just working with vertices seemed to make more sense. Note furthermore that Graph.findPath returns an iterator over a “list” of vertex labels, not over a “list” of vertex objects / positions. The vertex labels Graph uses should be the same that the outside caller used when calling addVertex to establish the vertices.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123