soldair / node-qrcode

qr code generator
MIT License
7.53k stars 628 forks source link

The build graph is incorrect when build an optimized segment sequence. #272

Open OTime-star opened 3 years ago

OTime-star commented 3 years ago

In the encoding process, we will construct a graph, and then use the single-source shortest path algorithm to find the optimal segment sequence, but the constructed graph seems to be problematic.

Keep other parameters as default, and then encode "ABCDEF123", you will get the following graph(Byte mode is omitted). image The cost from node ("ABCDEF[A]") to node ("123[A]") is 16, which is wrong, it should be 17.

soldair commented 3 years ago

If you would like to take a shot at making this work more correctly I'm happy to take a look at a pr

OTime-star commented 3 years ago

I created the PR, it is here https://github.com/soldair/node-qrcode/pull/273