From e108cb841f585e0d88e5f3c58e1f50d16cdf42e9 Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Wed, 12 Oct 2016 09:49:09 +1100 Subject: [PATCH] ng_restructuring: wire start to tops in idx order --- src/nfagraph/ng_restructuring.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nfagraph/ng_restructuring.cpp b/src/nfagraph/ng_restructuring.cpp index 46990330..3b30a689 100644 --- a/src/nfagraph/ng_restructuring.cpp +++ b/src/nfagraph/ng_restructuring.cpp @@ -52,7 +52,11 @@ namespace ue2 { static void wireStartToTops(NGHolder &g, const flat_set &tops, vector &tempEdges) { - for (NFAVertex v : tops) { + // Construct edges in vertex index order, for determinism. + vector ordered_tops(begin(tops), end(tops)); + sort(begin(ordered_tops), end(ordered_tops), make_index_ordering(g)); + + for (NFAVertex v : ordered_tops) { assert(!isLeafNode(v, g)); const NFAEdge &e = add_edge(g.start, v, g).first;