Skip to contents

The kanji distance is based on matching hierarchical component structures in a nesting-free way across all levels. The cost for matching individual components is a cost for registering the components (i.e. alligning there position, scale and aspect ratio) plus the (relative unbalanced) Wasserstein distance between the registered components.

Usage

kanjidist(
  k1,
  k2,
  compo_seg_depth1 = 3,
  compo_seg_depth2 = 3,
  p = 1,
  C = 0.2,
  approx = c("grid", "pc", "pcweighted"),
  type = c("rtt", "unbalanced", "balanced"),
  size = 48,
  lwd = 2.5,
  density = 30,
  verbose = FALSE,
  minor_warnings = TRUE
)

Arguments

k1, k2

two objects of type kanjivec.

compo_seg_depth1, compo_seg_depth2

two integers \(\geq 1\). Specifies for each kanji the deepest level included for component matching. If 1, only the kanji itself is used.

p

the order of the Wasserstein distance used for matching components. All distances and the penalty (if any) are taken to the p-th power (which is compensated by taking the p-th root after summation).

C

the penalty for extra mass if type is "rtt" or "unbalanced", i.e. we add C^p per unit of extra mass (before applying the p-th root).

approx

what kind of approximation is used for matching components. If this is "grid", a bitmap (raster image) is used, otherwise lines are approximated by more freely spaced points. For "pc" (point cloud) each point has the same weight and points are placed in a (more or less) equidistant way. For "pcweighted" points are further apart along straight lines and around the center of the Bezier curves that describe the strokes. The weights of the points are then (more or less) proportional to the amount of ink (stroke length) they represent.

type

the type of Wasserstein distance used for matching components based on the grid or point cloud approximation chosen. "unbalanced" means the weights (pixel values if approx = "grid) are interpreted as mass. The total masses in two components be very different. Extra mass can be disposed of at cost C^p per unit. "rtt" is computationally the same, but the final distance is divided by the maximum of the total ink (sum of weights) in each component to the 1/p. "balanced" means the weights are normalized so that both images have the same total mass 1. Everything has to be transported, i.e.\ disposal of mass is not allowed.

size

side length of the bitmaps used for matching components (if approx = "grid).

lwd

linewidth for drawing the components in these bitmaps (if approx = "grid).

density

approximate number of discretization points per unit line length (if approx != "grid)

verbose

logical. Whether to print detailed information on the cost for all pairs of components and the final matching.

minor_warnings

logical. Should minor_warnings be given. If FALSE, the warnings about substantial distances between bitmaps/pointclouds standing for the same component and the use of a workaround due to missing strokes in component decompositions are suppressed. While these warnings indicate to same extent that things are not going exactly as planned, they are usually not of interest if a larger number of kanji distances is computed and obscure the visibility of more important warnings (if any).

Value

The kanji distance, a non-negative number.

Details

For the precise definition and details see the reference below. Parameter C corresponds to \(b/2^{1/p}\) in the paper.

Warning

[Experimental]
The interface and details of this function will change in the future. Currently only a minimal set of parameters can be passed. The other parameters are fixed exactly as in the "prototype distance" (4.1) of the reference below for better or worse.
There is a certain tendency that exact matches of components are rather strongly favored (if the KanjiVG elements agree this can overrule the unbalanced Wasserstein distance) and the penalties for translation/scaling/distortion of components are somewhat mild.
The computation time is rather high (depending on the settings and kanji up to several seconds per kanji pair). This can be alleviated somewhat by keeping the compo_seg_depth parameters at 3 or lower and setting size = 32 (which goes well with lwd=1.8).
Future versions will use a much faster line base optimal transport algorithm and further speed-ups.

References

Dominic Schuhmacher (2023).
Distance maps between Japanese kanji characters based on hierarchical optimal transport.
ArXiv, doi:10.48550/arXiv.2304.02493

Examples

if (requireNamespace("ROI.plugin.glpk")) {
  kanjidist(fivebetas[[4]], fivebetas[[5]])
  kanjidist(fivebetas[[4]], fivebetas[[5]], verbose=TRUE)
  # faster and similar:
  kanjidist(fivebetas[[4]], fivebetas[[5]], compo_seg_depth1=2, compo_seg_depth2=2, 
            size=32, lwd=1.8, verbose=TRUE) 
  # slower and similar:
  kanjidist(fivebetas[[4]], fivebetas[[5]], size=64, lwd=3.2, verbose=TRUE)
} 
#> Loading required namespace: ROI.plugin.glpk
#> [[1]]
#> [[1]][[1]]
#>   flatind1   flatind2     level1       ind1     level2       ind2    totcost 
#> 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 0.44659193 
#>       dist    psidist    weight1    weight2     transx     transy     scalex 
#> 0.07491261 0.44659193 1.00000000 1.00000000 0.02808986 0.01027523 0.99614823 
#>     scaley   distortx   distorty 
#> 1.01739130 0.97912005 1.00000000 
#> attr(,"elements")
#> [1] "郵" "陣"
#> 
#> [[1]][[2]]
#>     flatind1     flatind2       level1         ind1       level2         ind2 
#>  1.000000000  2.000000000  1.000000000  1.000000000  2.000000000  1.000000000 
#>      totcost         dist      psidist      weight1      weight2       transx 
#>  0.784655125  0.119777514  0.833771283  1.000000000  0.313539590 -0.242366644 
#>       transy       scalex       scaley     distortx     distorty 
#>  0.003627086  0.278411206  0.904819766  0.307697971  1.000000000 
#> attr(,"elements")
#> [1] "郵" "⻖"
#> 
#> [[1]][[3]]
#>   flatind1   flatind2     level1       ind1     level2       ind2    totcost 
#> 1.00000000 3.00000000 1.00000000 1.00000000 2.00000000 2.00000000 0.37410355 
#>       dist    psidist    weight1    weight2     transx     transy     scalex 
#> 0.07238802 0.41995049 1.00000000 0.68646041 0.13166785 0.01027523 0.72127316 
#>     scaley   distortx   distorty 
#> 1.01739130 0.70894370 1.00000000 
#> attr(,"elements")
#> [1] "郵" "車"
#> 
#> 
#> [[2]]
#> [[2]][[1]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  2.00000000  1.00000000  2.00000000  1.00000000  1.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.42253813  0.07673603  0.46580764  0.63596141  1.00000000  0.17344037 
#>      transy      scalex      scaley    distortx    distorty 
#> -0.04693199  1.62168054  1.18936564  1.36348359  1.00000000 
#> attr(,"elements")
#> [1] "垂" "陣"
#> 
#> [[2]][[2]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  2.00000000  2.00000000  2.00000000  1.00000000  2.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.73608926  0.11918274  0.83031550  0.63596141  0.31353959 -0.09701614 
#>      transy      scalex      scaley    distortx    distorty 
#> -0.05358014  0.45323981  1.05776562  0.42848794  1.00000000 
#> attr(,"elements")
#> [1] "垂" "⻖"
#> 
#> [[2]][[3]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  2.00000000  3.00000000  2.00000000  1.00000000  2.00000000  2.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.21167340  0.05209631  0.21823116  0.63596141  0.68646041  0.27701835 
#>      transy      scalex      scaley    distortx    distorty 
#> -0.04693199  1.17419738  1.18936564  0.98724677  1.00000000 
#> attr(,"elements")
#> [1] "垂" "車"
#> 
#> 
#> [[3]]
#> [[3]][[1]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  3.00000000  1.00000000  2.00000000  2.00000000  1.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.74031477  0.11324079  0.79309611  0.36403859  1.00000000 -0.22865325 
#>      transy      scalex      scaley    distortx    distorty 
#>  0.04949527  3.12609719  1.12934319  2.76806663  1.00000000 
#> attr(,"elements")
#> [1] "⻏" "陣"
#> 
#> [[3]][[2]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  3.00000000  2.00000000  2.00000000  2.00000000  2.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.09672928  0.02541194  0.04549936  0.36403859  0.31353959 -0.49910976 
#>      transy      scalex      scaley    distortx    distorty 
#>  0.04284713  0.87370581  1.00438448  0.86989178  1.00000000 
#> attr(,"elements")
#> [1] "⻏" "⻖"
#> 
#> [[3]][[3]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  3.00000000  3.00000000  2.00000000  2.00000000  2.00000000  2.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.71395276  0.11472293  0.80284298  0.36403859  0.68646041 -0.12507527 
#>      transy      scalex      scaley    distortx    distorty 
#>  0.04949527  2.26348843  1.12934319  2.00425208  1.00000000 
#> attr(,"elements")
#> [1] "⻏" "車"
#> 
#> 
#> [[4]]
#> [[4]][[1]]
#>   flatind1   flatind2     level1       ind1     level2       ind2    totcost 
#>  4.0000000  1.0000000  3.0000000  1.0000000  1.0000000  1.0000000  0.7793960 
#>       dist    psidist    weight1    weight2     transx     transy     scalex 
#>  0.1320157  0.8945627  0.2008847  1.0000000  0.1784862 -0.0793578  1.9756156 
#>     scaley   distortx   distorty 
#>  1.3153950  1.5019182  1.0000000 
#> attr(,"elements")
#> [1] "千" "陣"
#> 
#> [[4]][[2]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  4.00000000  2.00000000  3.00000000  1.00000000  2.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.72281488  0.11865299  0.82719668  0.20088472  0.31353959 -0.09197027 
#>      transy      scalex      scaley    distortx    distorty 
#> -0.08600594  0.55216033  1.16985017  0.47199235  1.00000000 
#> attr(,"elements")
#> [1] "千" "⻖"
#> 
#> [[4]][[3]]
#>   flatind1   flatind2     level1       ind1     level2       ind2    totcost 
#>  4.0000000  3.0000000  3.0000000  1.0000000  2.0000000  2.0000000  0.6703091 
#>       dist    psidist    weight1    weight2     transx     transy     scalex 
#>  0.1107852  0.7762636  0.2008847  0.6864604  0.2820642 -0.0793578  1.4304684 
#>     scaley   distortx   distorty 
#>  1.3153950  1.0874820  1.0000000 
#> attr(,"elements")
#> [1] "千" "車"
#> 
#> 
#> [[5]]
#> [[5]][[1]]
#>   flatind1   flatind2     level1       ind1     level2       ind2    totcost 
#>  5.0000000  1.0000000  3.0000000  2.0000000  1.0000000  1.0000000  0.8083822 
#>       dist    psidist    weight1    weight2     transx     transy     scalex 
#>  0.1308616  0.8896323  0.1967095  1.0000000  0.1734404 -0.0409633  1.6216805 
#>     scaley   distortx   distorty 
#>  3.3620690  0.9325356  1.9333333 
#> attr(,"elements")
#> [1] "g"  "陣"
#> 
#> [[5]][[2]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  5.00000000  2.00000000  3.00000000  2.00000000  2.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.81186521  0.12740729  0.87390974  0.19670949  0.31353959 -0.09701614 
#>      transy      scalex      scaley    distortx    distorty 
#> -0.04761145  0.45323981  2.99006532  0.29305836  1.93333333 
#> attr(,"elements")
#> [1] "g"  "⻖"
#> 
#> [[5]][[3]]
#>   flatind1   flatind2     level1       ind1     level2       ind2    totcost 
#>  5.0000000  3.0000000  3.0000000  2.0000000  2.0000000  2.0000000  0.7974040 
#>       dist    psidist    weight1    weight2     transx     transy     scalex 
#>  0.1232692  0.8530923  0.1967095  0.6864604  0.2770183 -0.0409633  1.1741974 
#>     scaley   distortx   distorty 
#>  3.3620690  0.6752137  1.9333333 
#> attr(,"elements")
#> [1] "g"  "車"
#> 
#> 
#> [[6]]
#> [[6]][[1]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#> 6.000000000 1.000000000 3.000000000 3.000000000 1.000000000 1.000000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#> 0.791288325 0.136493552 0.912232376 0.225647973 1.000000000 0.175825688 
#>      transy      scalex      scaley    distortx    distorty 
#> 0.005499199 2.012543040 1.407404223 1.429968027 1.000000000 
#> attr(,"elements")
#> [1] "土" "陣"
#> 
#> [[6]][[2]]
#>     flatind1     flatind2       level1         ind1       level2         ind2 
#>  6.000000000  2.000000000  3.000000000  3.000000000  2.000000000  1.000000000 
#>      totcost         dist      psidist      weight1      weight2       transx 
#>  0.826973335  0.153554807  0.960928225  0.225647973  0.313539590 -0.094630821 
#>       transy       scalex       scaley     distortx     distorty 
#> -0.001148944  0.562481086  1.251678832  0.449381320  1.000000000 
#> attr(,"elements")
#> [1] "土" "⻖"
#> 
#> [[6]][[3]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#> 6.000000000 3.000000000 3.000000000 3.000000000 2.000000000 2.000000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#> 0.727305007 0.122611823 0.849579789 0.225647973 0.686460410 0.279403670 
#>      transy      scalex      scaley    distortx    distorty 
#> 0.005499199 1.457206099 1.407404223 1.035385624 1.000000000 
#> attr(,"elements")
#> [1] "土" "車"
#> 
#> 
#> Overview of matches:
#> 
#>   labfrom labto      costs    masses   masses1   masses2
#> 1      ⻏    ⻖ 0.09672928 0.3135396 0.3640386 0.3135396
#> 2      垂    車 0.21167340 0.6359614 0.6359614 0.6864604
#> Unmatched at cost 0.25: 0.050499
#> 
#> Directly computed total cost based on this overview: 0.177569321326189
#> [[1]]
#> [[1]][[1]]
#>   flatind1   flatind2     level1       ind1     level2       ind2    totcost 
#> 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 0.43282427 
#>       dist    psidist    weight1    weight2     transx     transy     scalex 
#> 0.07360803 0.43282427 1.00000000 1.00000000 0.02808986 0.01027523 0.99614823 
#>     scaley   distortx   distorty 
#> 1.01739130 0.97912005 1.00000000 
#> attr(,"elements")
#> [1] "郵" "陣"
#> 
#> [[1]][[2]]
#>     flatind1     flatind2       level1         ind1       level2         ind2 
#>  1.000000000  2.000000000  1.000000000  1.000000000  2.000000000  1.000000000 
#>      totcost         dist      psidist      weight1      weight2       transx 
#>  0.780704076  0.118930021  0.828832472  1.000000000  0.313539590 -0.242366644 
#>       transy       scalex       scaley     distortx     distorty 
#>  0.003627086  0.278411206  0.904819766  0.307697971  1.000000000 
#> attr(,"elements")
#> [1] "郵" "⻖"
#> 
#> [[1]][[3]]
#>   flatind1   flatind2     level1       ind1     level2       ind2    totcost 
#> 1.00000000 3.00000000 1.00000000 1.00000000 2.00000000 2.00000000 0.36832288 
#>       dist    psidist    weight1    weight2     transx     transy     scalex 
#> 0.07170271 0.41272464 1.00000000 0.68646041 0.13166785 0.01027523 0.72127316 
#>     scaley   distortx   distorty 
#> 1.01739130 0.70894370 1.00000000 
#> attr(,"elements")
#> [1] "郵" "車"
#> 
#> 
#> [[2]]
#> [[2]][[1]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  2.00000000  1.00000000  2.00000000  1.00000000  1.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.41301626  0.07560606  0.45390530  0.63596141  1.00000000  0.17344037 
#>      transy      scalex      scaley    distortx    distorty 
#> -0.04693199  1.62168054  1.18936564  1.36348359  1.00000000 
#> attr(,"elements")
#> [1] "垂" "陣"
#> 
#> [[2]][[2]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  2.00000000  2.00000000  2.00000000  1.00000000  2.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.73097590  0.11810400  0.82392380  0.63596141  0.31353959 -0.09701614 
#>      transy      scalex      scaley    distortx    distorty 
#> -0.05358014  0.45323981  1.05776562  0.42848794  1.00000000 
#> attr(,"elements")
#> [1] "垂" "⻖"
#> 
#> [[2]][[3]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  2.00000000  3.00000000  2.00000000  1.00000000  2.00000000  2.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.20487990  0.05112955  0.20973929  0.63596141  0.68646041  0.27701835 
#>      transy      scalex      scaley    distortx    distorty 
#> -0.04693199  1.17419738  1.18936564  0.98724677  1.00000000 
#> attr(,"elements")
#> [1] "垂" "車"
#> 
#> 
#> [[3]]
#> [[3]][[1]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  3.00000000  1.00000000  2.00000000  2.00000000  1.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.73480196  0.11222037  0.78620510  0.36403859  1.00000000 -0.22865325 
#>      transy      scalex      scaley    distortx    distorty 
#>  0.04949527  3.12609719  1.12934319  2.76806663  1.00000000 
#> attr(,"elements")
#> [1] "⻏" "陣"
#> 
#> [[3]][[2]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  3.00000000  2.00000000  2.00000000  2.00000000  2.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.09582504  0.02512123  0.04436905  0.36403859  0.31353959 -0.49910976 
#>      transy      scalex      scaley    distortx    distorty 
#>  0.04284713  0.87370581  1.00438448  0.86989178  1.00000000 
#> attr(,"elements")
#> [1] "⻏" "⻖"
#> 
#> [[3]][[3]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  3.00000000  3.00000000  2.00000000  2.00000000  2.00000000  2.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.70976175  0.11392045  0.79760421  0.36403859  0.68646041 -0.12507527 
#>      transy      scalex      scaley    distortx    distorty 
#>  0.04949527  2.26348843  1.12934319  2.00425208  1.00000000 
#> attr(,"elements")
#> [1] "⻏" "車"
#> 
#> 
#> Overview of matches:
#> 
#>   labfrom labto      costs    masses   masses1   masses2
#> 1      ⻏    ⻖ 0.09582504 0.3135396 0.3640386 0.3135396
#> 2      垂    車 0.20487990 0.6359614 0.6359614 0.6864604
#> Unmatched at cost 0.25: 0.050499
#> 
#> Directly computed total cost based on this overview: 0.17296540263549
#> [[1]]
#> [[1]][[1]]
#>   flatind1   flatind2     level1       ind1     level2       ind2    totcost 
#> 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 0.45376699 
#>       dist    psidist    weight1    weight2     transx     transy     scalex 
#> 0.07559294 0.45376699 1.00000000 1.00000000 0.02808986 0.01027523 0.99614823 
#>     scaley   distortx   distorty 
#> 1.01739130 0.97912005 1.00000000 
#> attr(,"elements")
#> [1] "郵" "陣"
#> 
#> [[1]][[2]]
#>     flatind1     flatind2       level1         ind1       level2         ind2 
#>  1.000000000  2.000000000  1.000000000  1.000000000  2.000000000  1.000000000 
#>      totcost         dist      psidist      weight1      weight2       transx 
#>  0.787058568  0.120301477  0.836775587  1.000000000  0.313539590 -0.242366644 
#>       transy       scalex       scaley     distortx     distorty 
#>  0.003627086  0.278411206  0.904819766  0.307697971  1.000000000 
#> attr(,"elements")
#> [1] "郵" "⻖"
#> 
#> [[1]][[3]]
#>   flatind1   flatind2     level1       ind1     level2       ind2    totcost 
#> 1.00000000 3.00000000 1.00000000 1.00000000 2.00000000 2.00000000 0.37875934 
#>       dist    psidist    weight1    weight2     transx     transy     scalex 
#> 0.07293964 0.42577022 1.00000000 0.68646041 0.13166785 0.01027523 0.72127316 
#>     scaley   distortx   distorty 
#> 1.01739130 0.70894370 1.00000000 
#> attr(,"elements")
#> [1] "郵" "車"
#> 
#> 
#> [[2]]
#> [[2]][[1]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  2.00000000  1.00000000  2.00000000  1.00000000  1.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.42776207  0.07735700  0.47233756  0.63596141  1.00000000  0.17344037 
#>      transy      scalex      scaley    distortx    distorty 
#> -0.04693199  1.62168054  1.18936564  1.36348359  1.00000000 
#> attr(,"elements")
#> [1] "垂" "陣"
#> 
#> [[2]][[2]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  2.00000000  2.00000000  2.00000000  1.00000000  2.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.73870009  0.11974420  0.83357902  0.63596141  0.31353959 -0.09701614 
#>      transy      scalex      scaley    distortx    distorty 
#> -0.05358014  0.45323981  1.05776562  0.42848794  1.00000000 
#> attr(,"elements")
#> [1] "垂" "⻖"
#> 
#> [[2]][[3]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  2.00000000  3.00000000  2.00000000  1.00000000  2.00000000  2.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.21513288  0.05258259  0.22255551  0.63596141  0.68646041  0.27701835 
#>      transy      scalex      scaley    distortx    distorty 
#> -0.04693199  1.17419738  1.18936564  0.98724677  1.00000000 
#> attr(,"elements")
#> [1] "垂" "車"
#> 
#> 
#> [[3]]
#> [[3]][[1]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  3.00000000  1.00000000  2.00000000  2.00000000  1.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.74109286  0.11338660  0.79406872  0.36403859  1.00000000 -0.22865325 
#>      transy      scalex      scaley    distortx    distorty 
#>  0.04949527  3.12609719  1.12934319  2.76806663  1.00000000 
#> attr(,"elements")
#> [1] "⻏" "陣"
#> 
#> [[3]][[2]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  3.00000000  2.00000000  2.00000000  2.00000000  2.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.09572261  0.02508803  0.04424102  0.36403859  0.31353959 -0.49910976 
#>      transy      scalex      scaley    distortx    distorty 
#>  0.04284713  0.87370581  1.00438448  0.86989178  1.00000000 
#> attr(,"elements")
#> [1] "⻏" "⻖"
#> 
#> [[3]][[3]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  3.00000000  3.00000000  2.00000000  2.00000000  2.00000000  2.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.71596209  0.11511267  0.80535464  0.36403859  0.68646041 -0.12507527 
#>      transy      scalex      scaley    distortx    distorty 
#>  0.04949527  2.26348843  1.12934319  2.00425208  1.00000000 
#> attr(,"elements")
#> [1] "⻏" "車"
#> 
#> 
#> [[4]]
#> [[4]][[1]]
#>   flatind1   flatind2     level1       ind1     level2       ind2    totcost 
#>  4.0000000  1.0000000  3.0000000  1.0000000  1.0000000  1.0000000  0.7807105 
#>       dist    psidist    weight1    weight2     transx     transy     scalex 
#>  0.1324087  0.8962058  0.2008847  1.0000000  0.1784862 -0.0793578  1.9756156 
#>     scaley   distortx   distorty 
#>  1.3153950  1.5019182  1.0000000 
#> attr(,"elements")
#> [1] "千" "陣"
#> 
#> [[4]][[2]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  4.00000000  2.00000000  3.00000000  1.00000000  2.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.72577322  0.11928183  0.83089460  0.20088472  0.31353959 -0.09197027 
#>      transy      scalex      scaley    distortx    distorty 
#> -0.08600594  0.55216033  1.16985017  0.47199235  1.00000000 
#> attr(,"elements")
#> [1] "千" "⻖"
#> 
#> [[4]][[3]]
#>   flatind1   flatind2     level1       ind1     level2       ind2    totcost 
#>  4.0000000  3.0000000  3.0000000  1.0000000  2.0000000  2.0000000  0.6729803 
#>       dist    psidist    weight1    weight2     transx     transy     scalex 
#>  0.1112626  0.7796025  0.2008847  0.6864604  0.2820642 -0.0793578  1.4304684 
#>     scaley   distortx   distorty 
#>  1.3153950  1.0874820  1.0000000 
#> attr(,"elements")
#> [1] "千" "車"
#> 
#> 
#> [[5]]
#> [[5]][[1]]
#>   flatind1   flatind2     level1       ind1     level2       ind2    totcost 
#>  5.0000000  1.0000000  3.0000000  2.0000000  1.0000000  1.0000000  0.8094450 
#>       dist    psidist    weight1    weight2     transx     transy     scalex 
#>  0.1311689  0.8909607  0.1967095  1.0000000  0.1734404 -0.0409633  1.6216805 
#>     scaley   distortx   distorty 
#>  3.3620690  0.9325356  1.9333333 
#> attr(,"elements")
#> [1] "g"  "陣"
#> 
#> [[5]][[2]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#>  5.00000000  2.00000000  3.00000000  2.00000000  2.00000000  1.00000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#>  0.81393038  0.12795289  0.87649119  0.19670949  0.31353959 -0.09701614 
#>      transy      scalex      scaley    distortx    distorty 
#> -0.04761145  0.45323981  2.99006532  0.29305836  1.93333333 
#> attr(,"elements")
#> [1] "g"  "⻖"
#> 
#> [[5]][[3]]
#>   flatind1   flatind2     level1       ind1     level2       ind2    totcost 
#>  5.0000000  3.0000000  3.0000000  2.0000000  2.0000000  2.0000000  0.7989914 
#>       dist    psidist    weight1    weight2     transx     transy     scalex 
#>  0.1236453  0.8550766  0.1967095  0.6864604  0.2770183 -0.0409633  1.1741974 
#>     scaley   distortx   distorty 
#>  3.3620690  0.6752137  1.9333333 
#> attr(,"elements")
#> [1] "g"  "車"
#> 
#> 
#> [[6]]
#> [[6]][[1]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#> 6.000000000 1.000000000 3.000000000 3.000000000 1.000000000 1.000000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#> 0.792221398 0.136810726 0.913398718 0.225647973 1.000000000 0.175825688 
#>      transy      scalex      scaley    distortx    distorty 
#> 0.005499199 2.012543040 1.407404223 1.429968027 1.000000000 
#> attr(,"elements")
#> [1] "土" "陣"
#> 
#> [[6]][[2]]
#>     flatind1     flatind2       level1         ind1       level2         ind2 
#>  6.000000000  2.000000000  3.000000000  3.000000000  2.000000000  1.000000000 
#>      totcost         dist      psidist      weight1      weight2       transx 
#>  0.828363169  0.154392617  0.962665517  0.225647973  0.313539590 -0.094630821 
#>       transy       scalex       scaley     distortx     distorty 
#> -0.001148944  0.562481086  1.251678832  0.449381320  1.000000000 
#> attr(,"elements")
#> [1] "土" "⻖"
#> 
#> [[6]][[3]]
#>    flatind1    flatind2      level1        ind1      level2        ind2 
#> 6.000000000 3.000000000 3.000000000 3.000000000 2.000000000 2.000000000 
#>     totcost        dist     psidist     weight1     weight2      transx 
#> 0.727824582 0.122732560 0.850229258 0.225647973 0.686460410 0.279403670 
#>      transy      scalex      scaley    distortx    distorty 
#> 0.005499199 1.457206099 1.407404223 1.035385624 1.000000000 
#> attr(,"elements")
#> [1] "土" "車"
#> 
#> 
#> Overview of matches:
#> 
#>   labfrom labto      costs    masses   masses1   masses2
#> 1      ⻏    ⻖ 0.09572261 0.3135396 0.3640386 0.3135396
#> 2      垂    車 0.21513288 0.6359614 0.6359614 0.6864604
#> Unmatched at cost 0.25: 0.050499
#> 
#> Directly computed total cost based on this overview: 0.179453784845399
#> [1] 0.1794538