Parcourir la source

A*最小路径

zzj il y a 6 ans
Parent
commit
d6fd178d42
1 fichiers modifiés avec 8 ajouts et 0 suppressions
  1. 8 0
      card_path.cpp

+ 8 - 0
card_path.cpp

@@ -798,12 +798,20 @@ struct graph
 			}
 		}
 
+		if(open_set.size()==0)
+		{
+			return {};
+		}
+
 		std::vector<point> rc;
 		while(cur.get())
 		{
 			rc.push_back(v[cur->vid]);
 			cur=cur->parent;
 		}
+
+		std::reverse(rc.begin(),rc.end());
+
 		return std::move(rc);
 	}