Open jsstylos opened 5 years ago
I put up a (temporary) web version for people to play around with and give feedback: https://jsstylos-sankeymatic.mybluemix.net
Tested it with the following data, that visualizes a ranked voting process:
' == ROUND 1 ==
' Candidates that move to the next round with all their votes:
Ana r1 [25] Ana r2
Ben r1 [20] Ben r2
Che r1 [16] Che r2
' Second choices for the least voted candidate:
Dan r1 [5] Ana r2
Dan r1 [4] Ben r2
Dan r1 [2] None r2
' == ROUND 2 ==
' Candidates that move to the next round with all their votes:
Ana r2 [*] Ana r3
Ben r2 [*] Ben r3
' Second choices for the least voted candidate:
Che r2 [3] Ana r3
Che r2 [11] Ben r3
Che r2 [*] None r3
(Here's a version of the script with more detailed comments explaining the numbers.)
Works quite well! Here's the result:
was this ever integrated? asking since the web version and this repo are not in synch so hard to tell.
This is a great suggestion!
This addresses #32 and (partially) #21, adding support for the [*] operator. This doesn't need a direction arrow because only one side can be unconstrained, so we can infer which direction; if both sides are unconstrained then the graph is unsolvable regardless.
The inference algorithm used requires that at each stage there be at least one node with a single computed/unknown edge, but this can be anywhere in the graph. This enables support for inputs where the only constraint is in the middle of the graph, such as:
More useful input would be something like:
The code could use some more testing and cleaning up, and has a known bug with generating console errors when given unsolvable input, but I'm putting the code up here for @nowthis and others to play around with.
Percentages would also be possible if this seems like a direction people are interested in.