Question 8: Fixed-Length Plans on a Ring¶
Consider a bidirectional ring of 10 nodes (0 through 9), where every adjacent pair is connected in both directions with edge weight 1, as shown in the figure above. To construct this graph, modify the below code (from valit_simple.py) that creates a linear bidirectional graph, without the ring structure:
#This example is a linear bidirectional graph of length g2_length.
g2_length = 20
G2 = nx.DiGraph()
G2.add_nodes_from([i for i in range(g2_length)])
for i in range(g2_length-1):
G2.add_edge(i, i+1, weight=1)
for i in range(1, g2_length):
G2.add_edge(i, i-1, weight=1)
Once you modified the above code to instead have the ring structure, use the fixed-length code from Question 7 and run it on the graph with goal = 0.
We use the same notation as in HW1:
- Let
G(x,k) be a comma-delimited string denoting the cost to go to state x on a fixed k-step path from states 0-9. We use the symbol X to denote that a fixed k-step path to the goal does not exist. - Let
G*(x) be a comma-delimited string denoting the cost to go to state x indeterminate length path from states 0-9. We use the symbol X to denote that a path to the goal does not exist.
Which of the following are true?