{"algorithm":"closest-first","about":["Closest-first keeps a priority queue of vertices by their distance from the start, the sum of the edge weights along the best path found so far. It takes the nearest vertex it hasn't visited, then puts each unvisited neighbor in the queue at the distance through that vertex, or moves it up the queue if that distance is shorter than the one it has. The vertices come out in order of distance, nearest first.","It is Dijkstra's algorithm as an iterator. traverse.ClosestFirst returns an iter.Seq2 of each vertex with its distance, and each one it yields is final, so a range loop can break at the vertex it needs without settling the rest of the graph. It costs O(E log V). Edge weights must not be negative, or a vertex can come out before a cheaper path to it is found.","Use it when the order matters, such as the three stores nearest to a home, and path.Dijkstra when you need the distance to every vertex at once."],"template":{"id":"downtown-grid","name":"Downtown grid","description":"Twenty intersections on a downtown street grid. Streets go both ways, Market is closed to cars between 2nd and 3rd, and each edge is the travel time in minutes.","family":"road","directed":true,"weighted":true,"acyclic":false,"vertices":[{"id":"Pine & 1st","x":76,"y":156},{"id":"Pine & 2nd","x":283,"y":188},{"id":"Pine & 3rd","x":496,"y":189},{"id":"Pine & 4th","x":706,"y":160},{"id":"Pine & 5th","x":931,"y":161},{"id":"Main & 1st","x":68,"y":383},{"id":"Main & 2nd","x":268,"y":404},{"id":"Main & 3rd","x":518,"y":374},{"id":"Main & 4th","x":739,"y":393},{"id":"Main & 5th","x":946,"y":381},{"id":"Market & 1st","x":73,"y":597},{"id":"Market & 2nd","x":276,"y":620},{"id":"Market & 3rd","x":512,"y":609},{"id":"Market & 4th","x":704,"y":593},{"id":"Market & 5th","x":958,"y":591},{"id":"River & 1st","x":53,"y":842},{"id":"River & 2nd","x":274,"y":833},{"id":"River & 3rd","x":489,"y":826},{"id":"River & 4th","x":701,"y":833},{"id":"River & 5th","x":950,"y":829}],"edges":[{"from":"Pine & 1st","to":"Pine & 2nd","weight":2},{"from":"Pine & 2nd","to":"Pine & 1st","weight":2},{"from":"Pine & 1st","to":"Main & 1st","weight":2},{"from":"Main & 1st","to":"Pine & 1st","weight":2},{"from":"Pine & 2nd","to":"Pine & 3rd","weight":3},{"from":"Pine & 3rd","to":"Pine & 2nd","weight":3},{"from":"Pine & 2nd","to":"Main & 2nd","weight":3},{"from":"Main & 2nd","to":"Pine & 2nd","weight":3},{"from":"Pine & 3rd","to":"Pine & 4th","weight":2},{"from":"Pine & 4th","to":"Pine & 3rd","weight":2},{"from":"Pine & 3rd","to":"Main & 3rd","weight":2},{"from":"Main & 3rd","to":"Pine & 3rd","weight":2},{"from":"Pine & 4th","to":"Pine & 5th","weight":3},{"from":"Pine & 5th","to":"Pine & 4th","weight":3},{"from":"Pine & 4th","to":"Main & 4th","weight":2},{"from":"Main & 4th","to":"Pine & 4th","weight":2},{"from":"Pine & 5th","to":"Main & 5th","weight":3},{"from":"Main & 5th","to":"Pine & 5th","weight":3},{"from":"Main & 1st","to":"Main & 2nd","weight":3},{"from":"Main & 2nd","to":"Main & 1st","weight":3},{"from":"Main & 1st","to":"Market & 1st","weight":3},{"from":"Market & 1st","to":"Main & 1st","weight":3},{"from":"Main & 2nd","to":"Main & 3rd","weight":4},{"from":"Main & 3rd","to":"Main & 2nd","weight":4},{"from":"Main & 2nd","to":"Market & 2nd","weight":2},{"from":"Market & 2nd","to":"Main & 2nd","weight":2},{"from":"Main & 3rd","to":"Main & 4th","weight":4},{"from":"Main & 4th","to":"Main & 3rd","weight":4},{"from":"Main & 3rd","to":"Market & 3rd","weight":3},{"from":"Market & 3rd","to":"Main & 3rd","weight":3},{"from":"Main & 4th","to":"Main & 5th","weight":3},{"from":"Main & 5th","to":"Main & 4th","weight":3},{"from":"Main & 4th","to":"Market & 4th","weight":2},{"from":"Market & 4th","to":"Main & 4th","weight":2},{"from":"Main & 5th","to":"Market & 5th","weight":2},{"from":"Market & 5th","to":"Main & 5th","weight":2},{"from":"Market & 1st","to":"Market & 2nd","weight":2},{"from":"Market & 2nd","to":"Market & 1st","weight":2},{"from":"Market & 1st","to":"River & 1st","weight":2},{"from":"River & 1st","to":"Market & 1st","weight":2},{"from":"Market & 2nd","to":"River & 2nd","weight":2},{"from":"River & 2nd","to":"Market & 2nd","weight":2},{"from":"Market & 3rd","to":"Market & 4th","weight":3},{"from":"Market & 4th","to":"Market & 3rd","weight":3},{"from":"Market & 3rd","to":"River & 3rd","weight":3},{"from":"River & 3rd","to":"Market & 3rd","weight":3},{"from":"Market & 4th","to":"Market & 5th","weight":2},{"from":"Market & 5th","to":"Market & 4th","weight":2},{"from":"Market & 4th","to":"River & 4th","weight":3},{"from":"River & 4th","to":"Market & 4th","weight":3},{"from":"Market & 5th","to":"River & 5th","weight":2},{"from":"River & 5th","to":"Market & 5th","weight":2},{"from":"River & 1st","to":"River & 2nd","weight":3},{"from":"River & 2nd","to":"River & 1st","weight":3},{"from":"River & 2nd","to":"River & 3rd","weight":2},{"from":"River & 3rd","to":"River & 2nd","weight":2},{"from":"River & 3rd","to":"River & 4th","weight":2},{"from":"River & 4th","to":"River & 3rd","weight":2},{"from":"River & 4th","to":"River & 5th","weight":4},{"from":"River & 5th","to":"River & 4th","weight":4}],"details":{"vertices":20,"edges":60,"directed":true,"weighted":true,"acyclic":false,"weightMin":2,"weightMax":4,"negativeWeights":false,"density":0.15789473684210525,"inDegree":{"min":2,"avg":3,"max":4},"outDegree":{"min":2,"avg":3,"max":4},"selfLoops":0,"components":1}},"problem":"List the intersections you can reach from Pine & 1st, nearest by travel time first.","params":{"start":"Pine & 1st"},"result":{"kind":"order","vertices":["Pine \u0026 1st","Pine \u0026 2nd","Main \u0026 1st","Main \u0026 2nd","Market \u0026 1st","Pine \u0026 3rd","River \u0026 1st","Pine \u0026 4th","Market \u0026 2nd","Main \u0026 3rd","Main \u0026 4th","River \u0026 2nd","Pine \u0026 5th","Market \u0026 3rd","Market \u0026 4th","River \u0026 3rd","Main \u0026 5th","Market \u0026 5th","River \u0026 4th","River \u0026 5th"]},"answer":"From Pine & 1st, closest-first visits 20 vertices, nearest first: Pine & 1st, Pine & 2nd, Main & 1st, Main & 2nd, Market & 1st, Pine & 3rd, River & 1st, Pine & 4th, Market & 2nd, Main & 3rd, and so on to River & 5th.","legend":{"vertex":[{"id":"idle","label":"Not reached","color":"#64748B","shape":"hollow"},{"id":"waiting","label":"In queue","color":"#E69F00","shape":"dashed-square"},{"id":"current","label":"Current","color":"#56B4E9","shape":"ring"},{"id":"done","label":"Visited","color":"#009E73","shape":"filled"}],"edge":[{"id":"idle","label":"Edge","color":"#475569","shape":"line"},{"id":"tree","label":"Used to reach a vertex","color":"#009E73","shape":"thick"},{"id":"examined","label":"Checked, not used","color":"#CC79A7","shape":"dashed"}],"panels":[{"id":"queue","title":"Priority queue","kind":"list"},{"id":"dist","title":"Distances","kind":"table"},{"id":"order","title":"Visit order","kind":"list"}]},"steps":[{"say":"Every distance starts at ∞, except Pine & 1st, which is 0. Put Pine & 1st in the queue at 0.","ops":[{"v":"Pine & 1st","state":"waiting"},{"panel":"dist","set":{"Pine & 1st":"0"}},{"panel":"dist","set":{"Pine & 2nd":"∞"}},{"panel":"dist","set":{"Pine & 3rd":"∞"}},{"panel":"dist","set":{"Pine & 4th":"∞"}},{"panel":"dist","set":{"Pine & 5th":"∞"}},{"panel":"dist","set":{"Main & 1st":"∞"}},{"panel":"dist","set":{"Main & 2nd":"∞"}},{"panel":"dist","set":{"Main & 3rd":"∞"}},{"panel":"dist","set":{"Main & 4th":"∞"}},{"panel":"dist","set":{"Main & 5th":"∞"}},{"panel":"dist","set":{"Market & 1st":"∞"}},{"panel":"dist","set":{"Market & 2nd":"∞"}},{"panel":"dist","set":{"Market & 3rd":"∞"}},{"panel":"dist","set":{"Market & 4th":"∞"}},{"panel":"dist","set":{"Market & 5th":"∞"}},{"panel":"dist","set":{"River & 1st":"∞"}},{"panel":"dist","set":{"River & 2nd":"∞"}},{"panel":"dist","set":{"River & 3rd":"∞"}},{"panel":"dist","set":{"River & 4th":"∞"}},{"panel":"dist","set":{"River & 5th":"∞"}},{"panel":"queue","list":[{"key":"Pine & 1st","note":"0"}]}]},{"say":"Take Pine & 1st from the front of the queue and visit it. Its distance is 0.","ops":[{"v":"Pine & 1st","state":"current"},{"panel":"queue","list":[]},{"panel":"order","list":[{"key":"Pine & 1st"}]}]},{"say":"Pine & 1st to Pine & 2nd: 0 + 2 = 2. Put Pine & 2nd in the queue at 2.","ops":[{"v":"Pine & 2nd","state":"waiting"},{"panel":"dist","set":{"Pine & 2nd":"2"}},{"e":["Pine & 1st","Pine & 2nd"],"state":"examined"},{"panel":"queue","list":[{"key":"Pine & 2nd","note":"2"}]}]},{"say":"Pine & 1st to Main & 1st: 0 + 2 = 2. Put Main & 1st in the queue at 2.","ops":[{"v":"Main & 1st","state":"waiting"},{"panel":"dist","set":{"Main & 1st":"2"}},{"e":["Pine & 1st","Main & 1st"],"state":"examined"},{"panel":"queue","list":[{"key":"Pine & 2nd","note":"2"},{"key":"Main & 1st","note":"2"}]}]},{"say":"Take Pine & 2nd from the front of the queue and visit it. Its distance is 2.","ops":[{"v":"Pine & 2nd","state":"current"},{"panel":"queue","list":[{"key":"Main & 1st","note":"2"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"}]},{"e":["Pine & 1st","Pine & 2nd"],"state":"tree"},{"v":"Pine & 1st","state":"done"}]},{"say":"Pine & 2nd to Pine & 3rd: 2 + 3 = 5. Put Pine & 3rd in the queue at 5.","ops":[{"v":"Pine & 3rd","state":"waiting"},{"panel":"dist","set":{"Pine & 3rd":"5"}},{"e":["Pine & 2nd","Pine & 3rd"],"state":"examined"},{"panel":"queue","list":[{"key":"Main & 1st","note":"2"},{"key":"Pine & 3rd","note":"5"}]}]},{"say":"Pine & 2nd to Main & 2nd: 2 + 3 = 5. Put Main & 2nd in the queue at 5.","ops":[{"v":"Main & 2nd","state":"waiting"},{"panel":"dist","set":{"Main & 2nd":"5"}},{"e":["Pine & 2nd","Main & 2nd"],"state":"examined"},{"panel":"queue","list":[{"key":"Main & 1st","note":"2"},{"key":"Main & 2nd","note":"5"},{"key":"Pine & 3rd","note":"5"}]}]},{"say":"Take Main & 1st from the front of the queue and visit it. Its distance is 2.","ops":[{"v":"Main & 1st","state":"current"},{"panel":"queue","list":[{"key":"Main & 2nd","note":"5"},{"key":"Pine & 3rd","note":"5"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"}]},{"e":["Pine & 1st","Main & 1st"],"state":"tree"},{"v":"Pine & 2nd","state":"done"}]},{"say":"Main & 1st to Main & 2nd: 2 + 3 = 5, not shorter than 5. Main & 2nd stays in the queue at 5.","ops":[{"e":["Main & 1st","Main & 2nd"],"state":"examined"},{"panel":"queue","list":[{"key":"Main & 2nd","note":"5"},{"key":"Pine & 3rd","note":"5"}]}]},{"say":"Main & 1st to Market & 1st: 2 + 3 = 5. Put Market & 1st in the queue at 5.","ops":[{"v":"Market & 1st","state":"waiting"},{"panel":"dist","set":{"Market & 1st":"5"}},{"e":["Main & 1st","Market & 1st"],"state":"examined"},{"panel":"queue","list":[{"key":"Main & 2nd","note":"5"},{"key":"Market & 1st","note":"5"},{"key":"Pine & 3rd","note":"5"}]}]},{"say":"Take Main & 2nd from the front of the queue and visit it. Its distance is 5.","ops":[{"v":"Main & 2nd","state":"current"},{"panel":"queue","list":[{"key":"Market & 1st","note":"5"},{"key":"Pine & 3rd","note":"5"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"}]},{"e":["Pine & 2nd","Main & 2nd"],"state":"tree"},{"v":"Main & 1st","state":"done"}]},{"say":"Main & 2nd to Main & 3rd: 5 + 4 = 9. Put Main & 3rd in the queue at 9.","ops":[{"v":"Main & 3rd","state":"waiting"},{"panel":"dist","set":{"Main & 3rd":"9"}},{"e":["Main & 2nd","Main & 3rd"],"state":"examined"},{"panel":"queue","list":[{"key":"Market & 1st","note":"5"},{"key":"Pine & 3rd","note":"5"},{"key":"Main & 3rd","note":"9"}]}]},{"say":"Main & 2nd to Market & 2nd: 5 + 2 = 7. Put Market & 2nd in the queue at 7.","ops":[{"v":"Market & 2nd","state":"waiting"},{"panel":"dist","set":{"Market & 2nd":"7"}},{"e":["Main & 2nd","Market & 2nd"],"state":"examined"},{"panel":"queue","list":[{"key":"Market & 1st","note":"5"},{"key":"Pine & 3rd","note":"5"},{"key":"Market & 2nd","note":"7"},{"key":"Main & 3rd","note":"9"}]}]},{"say":"Take Market & 1st from the front of the queue and visit it. Its distance is 5.","ops":[{"v":"Market & 1st","state":"current"},{"panel":"queue","list":[{"key":"Pine & 3rd","note":"5"},{"key":"Market & 2nd","note":"7"},{"key":"Main & 3rd","note":"9"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"}]},{"e":["Main & 1st","Market & 1st"],"state":"tree"},{"v":"Main & 2nd","state":"done"}]},{"say":"Market & 1st to Market & 2nd: 5 + 2 = 7, not shorter than 7. Market & 2nd stays in the queue at 7.","ops":[{"e":["Market & 1st","Market & 2nd"],"state":"examined"},{"panel":"queue","list":[{"key":"Pine & 3rd","note":"5"},{"key":"Market & 2nd","note":"7"},{"key":"Main & 3rd","note":"9"}]}]},{"say":"Market & 1st to River & 1st: 5 + 2 = 7. Put River & 1st in the queue at 7.","ops":[{"v":"River & 1st","state":"waiting"},{"panel":"dist","set":{"River & 1st":"7"}},{"e":["Market & 1st","River & 1st"],"state":"examined"},{"panel":"queue","list":[{"key":"Pine & 3rd","note":"5"},{"key":"River & 1st","note":"7"},{"key":"Market & 2nd","note":"7"},{"key":"Main & 3rd","note":"9"}]}]},{"say":"Take Pine & 3rd from the front of the queue and visit it. Its distance is 5.","ops":[{"v":"Pine & 3rd","state":"current"},{"panel":"queue","list":[{"key":"River & 1st","note":"7"},{"key":"Market & 2nd","note":"7"},{"key":"Main & 3rd","note":"9"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"}]},{"e":["Pine & 2nd","Pine & 3rd"],"state":"tree"},{"v":"Market & 1st","state":"done"}]},{"say":"Pine & 3rd to Pine & 4th: 5 + 2 = 7. Put Pine & 4th in the queue at 7.","ops":[{"v":"Pine & 4th","state":"waiting"},{"panel":"dist","set":{"Pine & 4th":"7"}},{"e":["Pine & 3rd","Pine & 4th"],"state":"examined"},{"panel":"queue","list":[{"key":"River & 1st","note":"7"},{"key":"Pine & 4th","note":"7"},{"key":"Market & 2nd","note":"7"},{"key":"Main & 3rd","note":"9"}]}]},{"say":"Pine & 3rd to Main & 3rd: 5 + 2 = 7, shorter than 9. Move Main & 3rd up the queue to 7.","ops":[{"panel":"dist","set":{"Main & 3rd":"7"}},{"e":["Pine & 3rd","Main & 3rd"],"state":"examined"},{"panel":"queue","list":[{"key":"River & 1st","note":"7"},{"key":"Pine & 4th","note":"7"},{"key":"Main & 3rd","note":"7"},{"key":"Market & 2nd","note":"7"}]}]},{"say":"Take River & 1st from the front of the queue and visit it. Its distance is 7.","ops":[{"v":"River & 1st","state":"current"},{"panel":"queue","list":[{"key":"Pine & 4th","note":"7"},{"key":"Main & 3rd","note":"7"},{"key":"Market & 2nd","note":"7"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"},{"key":"River & 1st"}]},{"e":["Market & 1st","River & 1st"],"state":"tree"},{"v":"Pine & 3rd","state":"done"}]},{"say":"River & 1st to River & 2nd: 7 + 3 = 10. Put River & 2nd in the queue at 10.","ops":[{"v":"River & 2nd","state":"waiting"},{"panel":"dist","set":{"River & 2nd":"10"}},{"e":["River & 1st","River & 2nd"],"state":"examined"},{"panel":"queue","list":[{"key":"Pine & 4th","note":"7"},{"key":"Market & 2nd","note":"7"},{"key":"Main & 3rd","note":"7"},{"key":"River & 2nd","note":"10"}]}]},{"say":"Take Pine & 4th from the front of the queue and visit it. Its distance is 7.","ops":[{"v":"Pine & 4th","state":"current"},{"panel":"queue","list":[{"key":"Market & 2nd","note":"7"},{"key":"Main & 3rd","note":"7"},{"key":"River & 2nd","note":"10"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"},{"key":"River & 1st"},{"key":"Pine & 4th"}]},{"e":["Pine & 3rd","Pine & 4th"],"state":"tree"},{"v":"River & 1st","state":"done"}]},{"say":"Pine & 4th to Pine & 5th: 7 + 3 = 10. Put Pine & 5th in the queue at 10.","ops":[{"v":"Pine & 5th","state":"waiting"},{"panel":"dist","set":{"Pine & 5th":"10"}},{"e":["Pine & 4th","Pine & 5th"],"state":"examined"},{"panel":"queue","list":[{"key":"Market & 2nd","note":"7"},{"key":"Main & 3rd","note":"7"},{"key":"Pine & 5th","note":"10"},{"key":"River & 2nd","note":"10"}]}]},{"say":"Pine & 4th to Main & 4th: 7 + 2 = 9. Put Main & 4th in the queue at 9.","ops":[{"v":"Main & 4th","state":"waiting"},{"panel":"dist","set":{"Main & 4th":"9"}},{"e":["Pine & 4th","Main & 4th"],"state":"examined"},{"panel":"queue","list":[{"key":"Market & 2nd","note":"7"},{"key":"Main & 3rd","note":"7"},{"key":"Main & 4th","note":"9"},{"key":"River & 2nd","note":"10"},{"key":"Pine & 5th","note":"10"}]}]},{"say":"Take Market & 2nd from the front of the queue and visit it. Its distance is 7.","ops":[{"v":"Market & 2nd","state":"current"},{"panel":"queue","list":[{"key":"Main & 3rd","note":"7"},{"key":"Main & 4th","note":"9"},{"key":"River & 2nd","note":"10"},{"key":"Pine & 5th","note":"10"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"},{"key":"River & 1st"},{"key":"Pine & 4th"},{"key":"Market & 2nd"}]},{"e":["Main & 2nd","Market & 2nd"],"state":"tree"},{"v":"Pine & 4th","state":"done"}]},{"say":"Market & 2nd to River & 2nd: 7 + 2 = 9, shorter than 10. Move River & 2nd up the queue to 9.","ops":[{"panel":"dist","set":{"River & 2nd":"9"}},{"e":["Market & 2nd","River & 2nd"],"state":"examined"},{"panel":"queue","list":[{"key":"Main & 3rd","note":"7"},{"key":"Main & 4th","note":"9"},{"key":"River & 2nd","note":"9"},{"key":"Pine & 5th","note":"10"}]}]},{"say":"Take Main & 3rd from the front of the queue and visit it. Its distance is 7.","ops":[{"v":"Main & 3rd","state":"current"},{"panel":"queue","list":[{"key":"Main & 4th","note":"9"},{"key":"River & 2nd","note":"9"},{"key":"Pine & 5th","note":"10"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"},{"key":"River & 1st"},{"key":"Pine & 4th"},{"key":"Market & 2nd"},{"key":"Main & 3rd"}]},{"e":["Pine & 3rd","Main & 3rd"],"state":"tree"},{"v":"Market & 2nd","state":"done"}]},{"say":"Main & 3rd to Main & 4th: 7 + 4 = 11, not shorter than 9. Main & 4th stays in the queue at 9.","ops":[{"e":["Main & 3rd","Main & 4th"],"state":"examined"},{"panel":"queue","list":[{"key":"Main & 4th","note":"9"},{"key":"River & 2nd","note":"9"},{"key":"Pine & 5th","note":"10"}]}]},{"say":"Main & 3rd to Market & 3rd: 7 + 3 = 10. Put Market & 3rd in the queue at 10.","ops":[{"v":"Market & 3rd","state":"waiting"},{"panel":"dist","set":{"Market & 3rd":"10"}},{"e":["Main & 3rd","Market & 3rd"],"state":"examined"},{"panel":"queue","list":[{"key":"Main & 4th","note":"9"},{"key":"River & 2nd","note":"9"},{"key":"Market & 3rd","note":"10"},{"key":"Pine & 5th","note":"10"}]}]},{"say":"Take Main & 4th from the front of the queue and visit it. Its distance is 9.","ops":[{"v":"Main & 4th","state":"current"},{"panel":"queue","list":[{"key":"River & 2nd","note":"9"},{"key":"Market & 3rd","note":"10"},{"key":"Pine & 5th","note":"10"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"},{"key":"River & 1st"},{"key":"Pine & 4th"},{"key":"Market & 2nd"},{"key":"Main & 3rd"},{"key":"Main & 4th"}]},{"e":["Pine & 4th","Main & 4th"],"state":"tree"},{"v":"Main & 3rd","state":"done"}]},{"say":"Main & 4th to Main & 5th: 9 + 3 = 12. Put Main & 5th in the queue at 12.","ops":[{"v":"Main & 5th","state":"waiting"},{"panel":"dist","set":{"Main & 5th":"12"}},{"e":["Main & 4th","Main & 5th"],"state":"examined"},{"panel":"queue","list":[{"key":"River & 2nd","note":"9"},{"key":"Pine & 5th","note":"10"},{"key":"Market & 3rd","note":"10"},{"key":"Main & 5th","note":"12"}]}]},{"say":"Main & 4th to Market & 4th: 9 + 2 = 11. Put Market & 4th in the queue at 11.","ops":[{"v":"Market & 4th","state":"waiting"},{"panel":"dist","set":{"Market & 4th":"11"}},{"e":["Main & 4th","Market & 4th"],"state":"examined"},{"panel":"queue","list":[{"key":"River & 2nd","note":"9"},{"key":"Pine & 5th","note":"10"},{"key":"Market & 3rd","note":"10"},{"key":"Market & 4th","note":"11"},{"key":"Main & 5th","note":"12"}]}]},{"say":"Take River & 2nd from the front of the queue and visit it. Its distance is 9.","ops":[{"v":"River & 2nd","state":"current"},{"panel":"queue","list":[{"key":"Pine & 5th","note":"10"},{"key":"Market & 3rd","note":"10"},{"key":"Market & 4th","note":"11"},{"key":"Main & 5th","note":"12"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"},{"key":"River & 1st"},{"key":"Pine & 4th"},{"key":"Market & 2nd"},{"key":"Main & 3rd"},{"key":"Main & 4th"},{"key":"River & 2nd"}]},{"e":["Market & 2nd","River & 2nd"],"state":"tree"},{"v":"Main & 4th","state":"done"}]},{"say":"River & 2nd to River & 3rd: 9 + 2 = 11. Put River & 3rd in the queue at 11.","ops":[{"v":"River & 3rd","state":"waiting"},{"panel":"dist","set":{"River & 3rd":"11"}},{"e":["River & 2nd","River & 3rd"],"state":"examined"},{"panel":"queue","list":[{"key":"Pine & 5th","note":"10"},{"key":"Market & 3rd","note":"10"},{"key":"Market & 4th","note":"11"},{"key":"River & 3rd","note":"11"},{"key":"Main & 5th","note":"12"}]}]},{"say":"Take Pine & 5th from the front of the queue and visit it. Its distance is 10.","ops":[{"v":"Pine & 5th","state":"current"},{"panel":"queue","list":[{"key":"Market & 3rd","note":"10"},{"key":"Market & 4th","note":"11"},{"key":"River & 3rd","note":"11"},{"key":"Main & 5th","note":"12"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"},{"key":"River & 1st"},{"key":"Pine & 4th"},{"key":"Market & 2nd"},{"key":"Main & 3rd"},{"key":"Main & 4th"},{"key":"River & 2nd"},{"key":"Pine & 5th"}]},{"e":["Pine & 4th","Pine & 5th"],"state":"tree"},{"v":"River & 2nd","state":"done"}]},{"say":"Pine & 5th to Main & 5th: 10 + 3 = 13, not shorter than 12. Main & 5th stays in the queue at 12.","ops":[{"e":["Pine & 5th","Main & 5th"],"state":"examined"},{"panel":"queue","list":[{"key":"Market & 3rd","note":"10"},{"key":"Market & 4th","note":"11"},{"key":"River & 3rd","note":"11"},{"key":"Main & 5th","note":"12"}]}]},{"say":"Take Market & 3rd from the front of the queue and visit it. Its distance is 10.","ops":[{"v":"Market & 3rd","state":"current"},{"panel":"queue","list":[{"key":"Market & 4th","note":"11"},{"key":"River & 3rd","note":"11"},{"key":"Main & 5th","note":"12"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"},{"key":"River & 1st"},{"key":"Pine & 4th"},{"key":"Market & 2nd"},{"key":"Main & 3rd"},{"key":"Main & 4th"},{"key":"River & 2nd"},{"key":"Pine & 5th"},{"key":"Market & 3rd"}]},{"e":["Main & 3rd","Market & 3rd"],"state":"tree"},{"v":"Pine & 5th","state":"done"}]},{"say":"Market & 3rd to Market & 4th: 10 + 3 = 13, not shorter than 11. Market & 4th stays in the queue at 11.","ops":[{"e":["Market & 3rd","Market & 4th"],"state":"examined"},{"panel":"queue","list":[{"key":"Market & 4th","note":"11"},{"key":"River & 3rd","note":"11"},{"key":"Main & 5th","note":"12"}]}]},{"say":"Market & 3rd to River & 3rd: 10 + 3 = 13, not shorter than 11. River & 3rd stays in the queue at 11.","ops":[{"e":["Market & 3rd","River & 3rd"],"state":"examined"},{"panel":"queue","list":[{"key":"Market & 4th","note":"11"},{"key":"River & 3rd","note":"11"},{"key":"Main & 5th","note":"12"}]}]},{"say":"Take Market & 4th from the front of the queue and visit it. Its distance is 11.","ops":[{"v":"Market & 4th","state":"current"},{"panel":"queue","list":[{"key":"River & 3rd","note":"11"},{"key":"Main & 5th","note":"12"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"},{"key":"River & 1st"},{"key":"Pine & 4th"},{"key":"Market & 2nd"},{"key":"Main & 3rd"},{"key":"Main & 4th"},{"key":"River & 2nd"},{"key":"Pine & 5th"},{"key":"Market & 3rd"},{"key":"Market & 4th"}]},{"e":["Main & 4th","Market & 4th"],"state":"tree"},{"v":"Market & 3rd","state":"done"}]},{"say":"Market & 4th to Market & 5th: 11 + 2 = 13. Put Market & 5th in the queue at 13.","ops":[{"v":"Market & 5th","state":"waiting"},{"panel":"dist","set":{"Market & 5th":"13"}},{"e":["Market & 4th","Market & 5th"],"state":"examined"},{"panel":"queue","list":[{"key":"River & 3rd","note":"11"},{"key":"Main & 5th","note":"12"},{"key":"Market & 5th","note":"13"}]}]},{"say":"Market & 4th to River & 4th: 11 + 3 = 14. Put River & 4th in the queue at 14.","ops":[{"v":"River & 4th","state":"waiting"},{"panel":"dist","set":{"River & 4th":"14"}},{"e":["Market & 4th","River & 4th"],"state":"examined"},{"panel":"queue","list":[{"key":"River & 3rd","note":"11"},{"key":"Main & 5th","note":"12"},{"key":"Market & 5th","note":"13"},{"key":"River & 4th","note":"14"}]}]},{"say":"Take River & 3rd from the front of the queue and visit it. Its distance is 11.","ops":[{"v":"River & 3rd","state":"current"},{"panel":"queue","list":[{"key":"Main & 5th","note":"12"},{"key":"Market & 5th","note":"13"},{"key":"River & 4th","note":"14"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"},{"key":"River & 1st"},{"key":"Pine & 4th"},{"key":"Market & 2nd"},{"key":"Main & 3rd"},{"key":"Main & 4th"},{"key":"River & 2nd"},{"key":"Pine & 5th"},{"key":"Market & 3rd"},{"key":"Market & 4th"},{"key":"River & 3rd"}]},{"e":["River & 2nd","River & 3rd"],"state":"tree"},{"v":"Market & 4th","state":"done"}]},{"say":"River & 3rd to River & 4th: 11 + 2 = 13, shorter than 14. Move River & 4th up the queue to 13.","ops":[{"panel":"dist","set":{"River & 4th":"13"}},{"e":["River & 3rd","River & 4th"],"state":"examined"},{"panel":"queue","list":[{"key":"Main & 5th","note":"12"},{"key":"Market & 5th","note":"13"},{"key":"River & 4th","note":"13"}]}]},{"say":"Take Main & 5th from the front of the queue and visit it. Its distance is 12.","ops":[{"v":"Main & 5th","state":"current"},{"panel":"queue","list":[{"key":"Market & 5th","note":"13"},{"key":"River & 4th","note":"13"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"},{"key":"River & 1st"},{"key":"Pine & 4th"},{"key":"Market & 2nd"},{"key":"Main & 3rd"},{"key":"Main & 4th"},{"key":"River & 2nd"},{"key":"Pine & 5th"},{"key":"Market & 3rd"},{"key":"Market & 4th"},{"key":"River & 3rd"},{"key":"Main & 5th"}]},{"e":["Main & 4th","Main & 5th"],"state":"tree"},{"v":"River & 3rd","state":"done"}]},{"say":"Main & 5th to Market & 5th: 12 + 2 = 14, not shorter than 13. Market & 5th stays in the queue at 13.","ops":[{"e":["Main & 5th","Market & 5th"],"state":"examined"},{"panel":"queue","list":[{"key":"Market & 5th","note":"13"},{"key":"River & 4th","note":"13"}]}]},{"say":"Take Market & 5th from the front of the queue and visit it. Its distance is 13.","ops":[{"v":"Market & 5th","state":"current"},{"panel":"queue","list":[{"key":"River & 4th","note":"13"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"},{"key":"River & 1st"},{"key":"Pine & 4th"},{"key":"Market & 2nd"},{"key":"Main & 3rd"},{"key":"Main & 4th"},{"key":"River & 2nd"},{"key":"Pine & 5th"},{"key":"Market & 3rd"},{"key":"Market & 4th"},{"key":"River & 3rd"},{"key":"Main & 5th"},{"key":"Market & 5th"}]},{"e":["Market & 4th","Market & 5th"],"state":"tree"},{"v":"Main & 5th","state":"done"}]},{"say":"Market & 5th to River & 5th: 13 + 2 = 15. Put River & 5th in the queue at 15.","ops":[{"v":"River & 5th","state":"waiting"},{"panel":"dist","set":{"River & 5th":"15"}},{"e":["Market & 5th","River & 5th"],"state":"examined"},{"panel":"queue","list":[{"key":"River & 4th","note":"13"},{"key":"River & 5th","note":"15"}]}]},{"say":"Take River & 4th from the front of the queue and visit it. Its distance is 13.","ops":[{"v":"River & 4th","state":"current"},{"panel":"queue","list":[{"key":"River & 5th","note":"15"}]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"},{"key":"River & 1st"},{"key":"Pine & 4th"},{"key":"Market & 2nd"},{"key":"Main & 3rd"},{"key":"Main & 4th"},{"key":"River & 2nd"},{"key":"Pine & 5th"},{"key":"Market & 3rd"},{"key":"Market & 4th"},{"key":"River & 3rd"},{"key":"Main & 5th"},{"key":"Market & 5th"},{"key":"River & 4th"}]},{"e":["River & 3rd","River & 4th"],"state":"tree"},{"v":"Market & 5th","state":"done"}]},{"say":"River & 4th to River & 5th: 13 + 4 = 17, not shorter than 15. River & 5th stays in the queue at 15.","ops":[{"e":["River & 4th","River & 5th"],"state":"examined"},{"panel":"queue","list":[{"key":"River & 5th","note":"15"}]}]},{"say":"Take River & 5th from the front of the queue and visit it. Its distance is 15. It has no unvisited neighbors.","ops":[{"v":"River & 5th","state":"current"},{"panel":"queue","list":[]},{"panel":"order","list":[{"key":"Pine & 1st"},{"key":"Pine & 2nd"},{"key":"Main & 1st"},{"key":"Main & 2nd"},{"key":"Market & 1st"},{"key":"Pine & 3rd"},{"key":"River & 1st"},{"key":"Pine & 4th"},{"key":"Market & 2nd"},{"key":"Main & 3rd"},{"key":"Main & 4th"},{"key":"River & 2nd"},{"key":"Pine & 5th"},{"key":"Market & 3rd"},{"key":"Market & 4th"},{"key":"River & 3rd"},{"key":"Main & 5th"},{"key":"Market & 5th"},{"key":"River & 4th"},{"key":"River & 5th"}]},{"e":["Market & 5th","River & 5th"],"state":"tree"},{"v":"River & 4th","state":"done"}]},{"say":"Done. Closest-first visited 20 vertices from Pine & 1st, nearest first.","ops":[{"v":"River & 5th","state":"done"}]}],"traceNote":"","verification":"The steps come from a step-by-step copy of the algorithm. Its result is checked against gograph's on every start.","snippet":"for v, dist := range traverse.ClosestFirst(g, \"Pine & 1st\") {\n\tfmt.Println(v.Label(), dist)\n}"}
