package com.skt.nugu.sampleapp.utils

import java.lang.Integer.max
import java.lang.Math.min

class SimilarityChecker {

    companion object {
        private const val korBegin = 44032
        private const val korEnd = 55203
        private const val chosungBase = 588
        private const val jungsungBase = 28
        private const val jaumBegin = 12593
        private const val jaumEnd = 12622
        private const val moumBegin = 12623
        private const val moumEnd = 12643

        private val chosungList = listOf('ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', 'ㅂ', 'ㅃ',
            'ㅅ', 'ㅆ', 'ㅇ' , 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ')

        private val jungsungList = listOf('ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ', 'ㅔ', 'ㅕ', 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ', 'ㅚ',
            'ㅛ', 'ㅜ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ')

        private val jongsungList = listOf(' ', 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', 'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ',
            'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ')
    }

    private fun getLevenshteinDistance(s1 : List<Char>, s2 : List<Char>): Int {
        val m = s1.size
        val n = s2.size

        val dp = Array(m + 1) { IntArray(n + 1) }

        for (i in 1..m) {
            dp[i][0] = i
        }

        for (j in 1..n) {
            dp[0][j] = j
        }

        var cost : Int
        for (i in 1..m) {
            for (j in 1..n) {
                cost = if (s1[i - 1] == s2[j - 1]) 0 else 1
                dp[i][j] = min(min(dp[i - 1][j] + 1, dp[i][j - 1] + 1), dp[i - 1][j - 1] + cost)
            }
        }
        return dp[m][n]
    }

    private fun getJamoLevenshteinDistance(s1 : String, s2 : String): Double {
        val m = s1.length
        val n = s2.length

        val dp = Array(m + 1) { DoubleArray(n + 1) }

        for (i in 1..m) {
            dp[i][0] = i.toDouble()
        }

        for (j in 1..n) {
            dp[0][j] = j.toDouble()
        }

        var cost : Double
        for (i in 1..m) {
            for (j in 1..n) {
                cost = subCost(s1[i-1], s2[j-1])
                dp[i][j] = min(min(dp[i - 1][j] + 1, dp[i][j - 1] + 1), dp[i - 1][j - 1] + cost)
            }
        }
        return dp[m][n]
    }

    private fun subCost(c1 : Char, c2 : Char) : Double {
        if (c1 == c2) {
            return 0.0
        }
        return getLevenshteinDistance(decompose(c1), decompose(c2)) / 3.0
    }

    fun findSimilarity(s1: String?, s2: String?): Double {
        if (s1.isNullOrEmpty() or s2.isNullOrEmpty()) return -1.0
        var result = -1.0
        val maxLength = max(s1!!.length, s2!!.length)
        if (maxLength > 0) {
           result =  (maxLength * 1.0 - getJamoLevenshteinDistance(s1, s2)) / maxLength * 1.0

        } else {
            result = 1.0
        }
        return result
    }

    fun decompose(c : Char) : List<Char> {
        if (!checkKorean(c)) {
            return emptyList()
        }
        var i = c.code
        if (i in jaumBegin..jaumEnd) {
            return listOf(c, ' ', ' ')
        }
        if (i in moumBegin..moumEnd) {
            return listOf(' ', c, ' ')
        }

        i -= korBegin
        val cho : Int = i / chosungBase
        val jung : Int = ( i - cho * chosungBase ) / jungsungBase
        val jong : Int = ( i - cho * chosungBase - jung * jungsungBase)

        return listOf(chosungList[cho], jungsungList[jung], jongsungList[jong])
    }

    fun compose(chosung : Char, jungsung : Char, jongsung : Char) : Char {
        val tmp = korBegin + chosungBase * chosungList.indexOf(chosung) + jungsungBase * jungsungList.indexOf(jungsung) +
                jongsungList.indexOf(jongsung)

        return tmp.toChar()
    }

    fun checkKorean(c : Char) : Boolean {
        val i = c.code
        return (i in korBegin..korEnd) or (i in jaumBegin..jaumEnd) or (i in moumBegin..moumEnd)
    }

}

Compiled from "SimilarityChecker.kt"
public final class com.skt.nugu.sampleapp.utils.SimilarityChecker {
  public static final com.skt.nugu.sampleapp.utils.SimilarityChecker$Companion Companion;

  private static final int korBegin;

  private static final int korEnd;

  private static final int chosungBase;

  private static final int jungsungBase;

  private static final int jaumBegin;

  private static final int jaumEnd;

  private static final int moumBegin;

  private static final int moumEnd;

  private static final java.util.List<java.lang.Character> chosungList;

  private static final java.util.List<java.lang.Character> jungsungList;

  private static final java.util.List<java.lang.Character> jongsungList;

  public com.skt.nugu.sampleapp.utils.SimilarityChecker();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  private final int getLevenshteinDistance(java.util.List<java.lang.Character>, java.util.List<java.lang.Character>);
    Code:
       0: aload_1
       1: invokeinterface #19,  1           // InterfaceMethod java/util/List.size:()I
       6: istore_3
       7: aload_2
       8: invokeinterface #19,  1           // InterfaceMethod java/util/List.size:()I
      13: istore        4
      15: iconst_0
      16: istore        6
      18: iload_3
      19: iconst_1
      20: iadd
      21: istore        7
      23: iload         7
      25: anewarray     #21                 // class "[I"
      28: astore        8
      30: iload         6
      32: iload         7
      34: if_icmpge     58
      37: iload         6
      39: istore        9
      41: aload         8
      43: iload         9
      45: iload         4
      47: iconst_1
      48: iadd
      49: newarray       int
      51: aastore
      52: iinc          6, 1
      55: goto          30
      58: aload         8
      60: astore        5
      62: iconst_1
      63: istore        6
      65: iload         6
      67: iload_3
      68: if_icmpgt     92
      71: aload         5
      73: iload         6
      75: aaload
      76: iconst_0
      77: iload         6
      79: iastore
      80: iload         6
      82: iload_3
      83: if_icmpeq     92
      86: iinc          6, 1
      89: goto          71
      92: iconst_1
      93: istore        6
      95: iload         6
      97: iload         4
      99: if_icmpgt     124
     102: aload         5
     104: iconst_0
     105: aaload
     106: iload         6
     108: iload         6
     110: iastore
     111: iload         6
     113: iload         4
     115: if_icmpeq     124
     118: iinc          6, 1
     121: goto          102
     124: iconst_0
     125: istore        6
     127: iconst_1
     128: istore        7
     130: iload         7
     132: iload_3
     133: if_icmpgt     266
     136: iconst_1
     137: istore        8
     139: iload         8
     141: iload         4
     143: if_icmpgt     254
     146: aload_1
     147: iload         7
     149: iconst_1
     150: isub
     151: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     156: checkcast     #27                 // class java/lang/Character
     159: invokevirtual #31                 // Method java/lang/Character.charValue:()C
     162: aload_2
     163: iload         8
     165: iconst_1
     166: isub
     167: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     172: checkcast     #27                 // class java/lang/Character
     175: invokevirtual #31                 // Method java/lang/Character.charValue:()C
     178: if_icmpne     185
     181: iconst_0
     182: goto          186
     185: iconst_1
     186: istore        6
     188: aload         5
     190: iload         7
     192: aaload
     193: iload         8
     195: aload         5
     197: iload         7
     199: iconst_1
     200: isub
     201: aaload
     202: iload         8
     204: iaload
     205: iconst_1
     206: iadd
     207: aload         5
     209: iload         7
     211: aaload
     212: iload         8
     214: iconst_1
     215: isub
     216: iaload
     217: iconst_1
     218: iadd
     219: invokestatic  #37                 // Method java/lang/Math.min:(II)I
     222: aload         5
     224: iload         7
     226: iconst_1
     227: isub
     228: aaload
     229: iload         8
     231: iconst_1
     232: isub
     233: iaload
     234: iload         6
     236: iadd
     237: invokestatic  #37                 // Method java/lang/Math.min:(II)I
     240: iastore
     241: iload         8
     243: iload         4
     245: if_icmpeq     254
     248: iinc          8, 1
     251: goto          146
     254: iload         7
     256: iload_3
     257: if_icmpeq     266
     260: iinc          7, 1
     263: goto          136
     266: aload         5
     268: iload_3
     269: aaload
     270: iload         4
     272: iaload
     273: ireturn

  private final double getJamoLevenshteinDistance(java.lang.String, java.lang.String);
    Code:
       0: aload_1
       1: invokevirtual #56                 // Method java/lang/String.length:()I
       4: istore_3
       5: aload_2
       6: invokevirtual #56                 // Method java/lang/String.length:()I
       9: istore        4
      11: iconst_0
      12: istore        6
      14: iload_3
      15: iconst_1
      16: iadd
      17: istore        7
      19: iload         7
      21: anewarray     #58                 // class "[D"
      24: astore        8
      26: iload         6
      28: iload         7
      30: if_icmpge     54
      33: iload         6
      35: istore        9
      37: aload         8
      39: iload         9
      41: iload         4
      43: iconst_1
      44: iadd
      45: newarray       double
      47: aastore
      48: iinc          6, 1
      51: goto          26
      54: aload         8
      56: astore        5
      58: iconst_1
      59: istore        6
      61: iload         6
      63: iload_3
      64: if_icmpgt     89
      67: aload         5
      69: iload         6
      71: aaload
      72: iconst_0
      73: iload         6
      75: i2d
      76: dastore
      77: iload         6
      79: iload_3
      80: if_icmpeq     89
      83: iinc          6, 1
      86: goto          67
      89: iconst_1
      90: istore        6
      92: iload         6
      94: iload         4
      96: if_icmpgt     122
      99: aload         5
     101: iconst_0
     102: aaload
     103: iload         6
     105: iload         6
     107: i2d
     108: dastore
     109: iload         6
     111: iload         4
     113: if_icmpeq     122
     116: iinc          6, 1
     119: goto          99
     122: dconst_0
     123: dstore        6
     125: iconst_1
     126: istore        8
     128: iload         8
     130: iload_3
     131: if_icmpgt     246
     134: iconst_1
     135: istore        9
     137: iload         9
     139: iload         4
     141: if_icmpgt     234
     144: aload_0
     145: aload_1
     146: iload         8
     148: iconst_1
     149: isub
     150: invokevirtual #62                 // Method java/lang/String.charAt:(I)C
     153: aload_2
     154: iload         9
     156: iconst_1
     157: isub
     158: invokevirtual #62                 // Method java/lang/String.charAt:(I)C
     161: invokespecial #66                 // Method subCost:(CC)D
     164: dstore        6
     166: aload         5
     168: iload         8
     170: aaload
     171: iload         9
     173: aload         5
     175: iload         8
     177: iconst_1
     178: isub
     179: aaload
     180: iload         9
     182: daload
     183: iconst_1
     184: i2d
     185: dadd
     186: aload         5
     188: iload         8
     190: aaload
     191: iload         9
     193: iconst_1
     194: isub
     195: daload
     196: iconst_1
     197: i2d
     198: dadd
     199: invokestatic  #69                 // Method java/lang/Math.min:(DD)D
     202: aload         5
     204: iload         8
     206: iconst_1
     207: isub
     208: aaload
     209: iload         9
     211: iconst_1
     212: isub
     213: daload
     214: dload         6
     216: dadd
     217: invokestatic  #69                 // Method java/lang/Math.min:(DD)D
     220: dastore
     221: iload         9
     223: iload         4
     225: if_icmpeq     234
     228: iinc          9, 1
     231: goto          144
     234: iload         8
     236: iload_3
     237: if_icmpeq     246
     240: iinc          8, 1
     243: goto          134
     246: aload         5
     248: iload_3
     249: aaload
     250: iload         4
     252: daload
     253: dreturn

  private final double subCost(char, char);
    Code:
       0: iload_1
       1: iload_2
       2: if_icmpne     7
       5: dconst_0
       6: dreturn
       7: aload_0
       8: aload_0
       9: iload_1
      10: invokevirtual #77                 // Method decompose:(C)Ljava/util/List;
      13: aload_0
      14: iload_2
      15: invokevirtual #77                 // Method decompose:(C)Ljava/util/List;
      18: invokespecial #79                 // Method getLevenshteinDistance:(Ljava/util/List;Ljava/util/List;)I
      21: i2d
      22: ldc2_w        #80                 // double 3.0d
      25: ddiv
      26: dreturn

  public final double findSimilarity(java.lang.String, java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #88                 // class java/lang/CharSequence
       4: astore_3
       5: aload_3
       6: ifnull        18
       9: aload_3
      10: invokeinterface #89,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      15: ifne          22
      18: iconst_1
      19: goto          23
      22: iconst_0
      23: aload_2
      24: checkcast     #88                 // class java/lang/CharSequence
      27: astore_3
      28: aload_3
      29: ifnull        41
      32: aload_3
      33: invokeinterface #89,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      38: ifne          45
      41: iconst_1
      42: goto          46
      45: iconst_0
      46: ior
      47: ifeq          54
      50: ldc2_w        #90                 // double -1.0d
      53: dreturn
      54: ldc2_w        #90                 // double -1.0d
      57: dstore_3
      58: aload_1
      59: dup
      60: invokestatic  #97                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      63: invokevirtual #56                 // Method java/lang/String.length:()I
      66: aload_2
      67: dup
      68: invokestatic  #97                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      71: invokevirtual #56                 // Method java/lang/String.length:()I
      74: invokestatic  #102                // Method java/lang/Integer.max:(II)I
      77: istore        5
      79: iload         5
      81: ifle          106
      84: iload         5
      86: i2d
      87: dconst_1
      88: dmul
      89: aload_0
      90: aload_1
      91: aload_2
      92: invokespecial #104                // Method getJamoLevenshteinDistance:(Ljava/lang/String;Ljava/lang/String;)D
      95: dsub
      96: iload         5
      98: i2d
      99: ddiv
     100: dconst_1
     101: dmul
     102: dstore_3
     103: goto          108
     106: dconst_1
     107: dstore_3
     108: dload_3
     109: dreturn

  public final java.util.List<java.lang.Character> decompose(char);
    Code:
       0: aload_0
       1: iload_1
       2: invokevirtual #112                // Method checkKorean:(C)Z
       5: ifne          12
       8: invokestatic  #118                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      11: areturn
      12: iload_1
      13: istore_2
      14: sipush        12593
      17: iload_2
      18: if_icmpgt     36
      21: iload_2
      22: sipush        12623
      25: if_icmpge     32
      28: iconst_1
      29: goto          37
      32: iconst_0
      33: goto          37
      36: iconst_0
      37: ifeq          73
      40: iconst_3
      41: anewarray     #27                 // class java/lang/Character
      44: astore_3
      45: aload_3
      46: iconst_0
      47: iload_1
      48: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      51: aastore
      52: aload_3
      53: iconst_1
      54: bipush        32
      56: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      59: aastore
      60: aload_3
      61: iconst_2
      62: bipush        32
      64: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      67: aastore
      68: aload_3
      69: invokestatic  #126                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      72: areturn
      73: sipush        12623
      76: iload_2
      77: if_icmpgt     95
      80: iload_2
      81: sipush        12644
      84: if_icmpge     91
      87: iconst_1
      88: goto          96
      91: iconst_0
      92: goto          96
      95: iconst_0
      96: ifeq          132
      99: iconst_3
     100: anewarray     #27                 // class java/lang/Character
     103: astore_3
     104: aload_3
     105: iconst_0
     106: bipush        32
     108: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     111: aastore
     112: aload_3
     113: iconst_1
     114: iload_1
     115: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     118: aastore
     119: aload_3
     120: iconst_2
     121: bipush        32
     123: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     126: aastore
     127: aload_3
     128: invokestatic  #126                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     131: areturn
     132: iload_2
     133: ldc           #127                // int 44032
     135: isub
     136: istore_2
     137: iload_2
     138: sipush        588
     141: idiv
     142: istore_3
     143: iload_2
     144: iload_3
     145: sipush        588
     148: imul
     149: isub
     150: bipush        28
     152: idiv
     153: istore        4
     155: iload_2
     156: iload_3
     157: sipush        588
     160: imul
     161: isub
     162: iload         4
     164: bipush        28
     166: imul
     167: isub
     168: istore        5
     170: iconst_3
     171: anewarray     #27                 // class java/lang/Character
     174: astore        6
     176: aload         6
     178: iconst_0
     179: getstatic     #130                // Field chosungList:Ljava/util/List;
     182: iload_3
     183: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     188: aastore
     189: aload         6
     191: iconst_1
     192: getstatic     #133                // Field jungsungList:Ljava/util/List;
     195: iload         4
     197: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     202: aastore
     203: aload         6
     205: iconst_2
     206: getstatic     #136                // Field jongsungList:Ljava/util/List;
     209: iload         5
     211: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     216: aastore
     217: aload         6
     219: invokestatic  #126                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     222: areturn

  public final char compose(char, char, char);
    Code:
       0: ldc           #127                // int 44032
       2: sipush        588
       5: getstatic     #130                // Field chosungList:Ljava/util/List;
       8: iload_1
       9: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      12: invokeinterface #146,  2          // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
      17: imul
      18: iadd
      19: bipush        28
      21: getstatic     #133                // Field jungsungList:Ljava/util/List;
      24: iload_2
      25: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      28: invokeinterface #146,  2          // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
      33: imul
      34: iadd
      35: getstatic     #136                // Field jongsungList:Ljava/util/List;
      38: iload_3
      39: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      42: invokeinterface #146,  2          // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
      47: iadd
      48: istore        4
      50: iload         4
      52: i2c
      53: ireturn

  public final boolean checkKorean(char);
    Code:
       0: iload_1
       1: istore_2
       2: ldc           #127                // int 44032
       4: iload_2
       5: if_icmpgt     22
       8: iload_2
       9: ldc           #151                // int 55204
      11: if_icmpge     18
      14: iconst_1
      15: goto          23
      18: iconst_0
      19: goto          23
      22: iconst_0
      23: sipush        12593
      26: iload_2
      27: if_icmpgt     45
      30: iload_2
      31: sipush        12623
      34: if_icmpge     41
      37: iconst_1
      38: goto          46
      41: iconst_0
      42: goto          46
      45: iconst_0
      46: ior
      47: sipush        12623
      50: iload_2
      51: if_icmpgt     69
      54: iload_2
      55: sipush        12644
      58: if_icmpge     65
      61: iconst_1
      62: goto          70
      65: iconst_0
      66: goto          70
      69: iconst_0
      70: ior
      71: ireturn

  static {};
    Code:
       0: new           #154                // class com/skt/nugu/sampleapp/utils/SimilarityChecker$Companion
       3: dup
       4: aconst_null
       5: invokespecial #157                // Method com/skt/nugu/sampleapp/utils/SimilarityChecker$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #161                // Field Companion:Lcom/skt/nugu/sampleapp/utils/SimilarityChecker$Companion;
      11: bipush        19
      13: anewarray     #27                 // class java/lang/Character
      16: astore_0
      17: aload_0
      18: iconst_0
      19: sipush        12593
      22: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      25: aastore
      26: aload_0
      27: iconst_1
      28: sipush        12594
      31: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      34: aastore
      35: aload_0
      36: iconst_2
      37: sipush        12596
      40: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      43: aastore
      44: aload_0
      45: iconst_3
      46: sipush        12599
      49: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      52: aastore
      53: aload_0
      54: iconst_4
      55: sipush        12600
      58: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      61: aastore
      62: aload_0
      63: iconst_5
      64: sipush        12601
      67: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      70: aastore
      71: aload_0
      72: bipush        6
      74: sipush        12609
      77: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      80: aastore
      81: aload_0
      82: bipush        7
      84: sipush        12610
      87: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      90: aastore
      91: aload_0
      92: bipush        8
      94: sipush        12611
      97: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     100: aastore
     101: aload_0
     102: bipush        9
     104: sipush        12613
     107: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     110: aastore
     111: aload_0
     112: bipush        10
     114: sipush        12614
     117: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     120: aastore
     121: aload_0
     122: bipush        11
     124: sipush        12615
     127: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     130: aastore
     131: aload_0
     132: bipush        12
     134: sipush        12616
     137: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     140: aastore
     141: aload_0
     142: bipush        13
     144: sipush        12617
     147: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     150: aastore
     151: aload_0
     152: bipush        14
     154: sipush        12618
     157: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     160: aastore
     161: aload_0
     162: bipush        15
     164: sipush        12619
     167: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     170: aastore
     171: aload_0
     172: bipush        16
     174: sipush        12620
     177: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     180: aastore
     181: aload_0
     182: bipush        17
     184: sipush        12621
     187: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     190: aastore
     191: aload_0
     192: bipush        18
     194: sipush        12622
     197: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     200: aastore
     201: aload_0
     202: invokestatic  #126                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     205: putstatic     #130                // Field chosungList:Ljava/util/List;
     208: bipush        21
     210: anewarray     #27                 // class java/lang/Character
     213: astore_0
     214: aload_0
     215: iconst_0
     216: sipush        12623
     219: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     222: aastore
     223: aload_0
     224: iconst_1
     225: sipush        12624
     228: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     231: aastore
     232: aload_0
     233: iconst_2
     234: sipush        12625
     237: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     240: aastore
     241: aload_0
     242: iconst_3
     243: sipush        12626
     246: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     249: aastore
     250: aload_0
     251: iconst_4
     252: sipush        12627
     255: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     258: aastore
     259: aload_0
     260: iconst_5
     261: sipush        12628
     264: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     267: aastore
     268: aload_0
     269: bipush        6
     271: sipush        12629
     274: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     277: aastore
     278: aload_0
     279: bipush        7
     281: sipush        12630
     284: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     287: aastore
     288: aload_0
     289: bipush        8
     291: sipush        12631
     294: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     297: aastore
     298: aload_0
     299: bipush        9
     301: sipush        12632
     304: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     307: aastore
     308: aload_0
     309: bipush        10
     311: sipush        12633
     314: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     317: aastore
     318: aload_0
     319: bipush        11
     321: sipush        12634
     324: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     327: aastore
     328: aload_0
     329: bipush        12
     331: sipush        12635
     334: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     337: aastore
     338: aload_0
     339: bipush        13
     341: sipush        12636
     344: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     347: aastore
     348: aload_0
     349: bipush        14
     351: sipush        12637
     354: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     357: aastore
     358: aload_0
     359: bipush        15
     361: sipush        12638
     364: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     367: aastore
     368: aload_0
     369: bipush        16
     371: sipush        12639
     374: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     377: aastore
     378: aload_0
     379: bipush        17
     381: sipush        12640
     384: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     387: aastore
     388: aload_0
     389: bipush        18
     391: sipush        12641
     394: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     397: aastore
     398: aload_0
     399: bipush        19
     401: sipush        12642
     404: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     407: aastore
     408: aload_0
     409: bipush        20
     411: sipush        12643
     414: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     417: aastore
     418: aload_0
     419: invokestatic  #126                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     422: putstatic     #133                // Field jungsungList:Ljava/util/List;
     425: bipush        28
     427: anewarray     #27                 // class java/lang/Character
     430: astore_0
     431: aload_0
     432: iconst_0
     433: bipush        32
     435: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     438: aastore
     439: aload_0
     440: iconst_1
     441: sipush        12593
     444: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     447: aastore
     448: aload_0
     449: iconst_2
     450: sipush        12594
     453: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     456: aastore
     457: aload_0
     458: iconst_3
     459: sipush        12595
     462: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     465: aastore
     466: aload_0
     467: iconst_4
     468: sipush        12596
     471: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     474: aastore
     475: aload_0
     476: iconst_5
     477: sipush        12597
     480: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     483: aastore
     484: aload_0
     485: bipush        6
     487: sipush        12598
     490: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     493: aastore
     494: aload_0
     495: bipush        7
     497: sipush        12599
     500: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     503: aastore
     504: aload_0
     505: bipush        8
     507: sipush        12601
     510: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     513: aastore
     514: aload_0
     515: bipush        9
     517: sipush        12602
     520: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     523: aastore
     524: aload_0
     525: bipush        10
     527: sipush        12603
     530: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     533: aastore
     534: aload_0
     535: bipush        11
     537: sipush        12604
     540: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     543: aastore
     544: aload_0
     545: bipush        12
     547: sipush        12605
     550: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     553: aastore
     554: aload_0
     555: bipush        13
     557: sipush        12606
     560: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     563: aastore
     564: aload_0
     565: bipush        14
     567: sipush        12607
     570: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     573: aastore
     574: aload_0
     575: bipush        15
     577: sipush        12608
     580: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     583: aastore
     584: aload_0
     585: bipush        16
     587: sipush        12609
     590: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     593: aastore
     594: aload_0
     595: bipush        17
     597: sipush        12610
     600: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     603: aastore
     604: aload_0
     605: bipush        18
     607: sipush        12612
     610: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     613: aastore
     614: aload_0
     615: bipush        19
     617: sipush        12613
     620: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     623: aastore
     624: aload_0
     625: bipush        20
     627: sipush        12614
     630: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     633: aastore
     634: aload_0
     635: bipush        21
     637: sipush        12615
     640: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     643: aastore
     644: aload_0
     645: bipush        22
     647: sipush        12616
     650: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     653: aastore
     654: aload_0
     655: bipush        23
     657: sipush        12618
     660: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     663: aastore
     664: aload_0
     665: bipush        24
     667: sipush        12619
     670: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     673: aastore
     674: aload_0
     675: bipush        25
     677: sipush        12620
     680: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     683: aastore
     684: aload_0
     685: bipush        26
     687: sipush        12621
     690: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     693: aastore
     694: aload_0
     695: bipush        27
     697: sipush        12622
     700: invokestatic  #122                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     703: aastore
     704: aload_0
     705: invokestatic  #126                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     708: putstatic     #136                // Field jongsungList:Ljava/util/List;
     711: return
}

Compiled from "SimilarityChecker.kt"
public final class com.skt.nugu.sampleapp.utils.SimilarityChecker$Companion {
  private com.skt.nugu.sampleapp.utils.SimilarityChecker$Companion();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public com.skt.nugu.sampleapp.utils.SimilarityChecker$Companion(kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: aload_0
       1: invokespecial #12                 // Method "<init>":()V
       4: return
}


package com.gitTraining

fun computeFibbonaciNumber(position: Int?, recursion: Boolean = false): Int {
    var notNullPosition = position
    if (notNullPosition == null) {
        notNullPosition = 1
    }
    if (recursion) return recursiveFibbonachi(1, 1, notNullPosition - 2)
    if (notNullPosition == 0) return 0
    if (notNullPosition < 0) {
        return computeNegativeFibbonachi(notNullPosition)
    }

    if (notNullPosition == 1 || notNullPosition == 2) return 1

    var smallFibbonachiNumber = 1
    var largeFibbonachiNumber = 1

    var currentPosition = 2
    while (currentPosition < notNullPosition) {
        val nextFibbonachiNumber = smallFibbonachiNumber + largeFibbonachiNumber
        smallFibbonachiNumber = largeFibbonachiNumber
        largeFibbonachiNumber = nextFibbonachiNumber
        currentPosition ++
    }
    return largeFibbonachiNumber
}

fun computeFibbonachiArray(start: Int, end: Int, efficient: Boolean = false): List<Int> {
    if (!efficient) return (start..end).map { computeFibbonaciNumber(it) }
    if (start > end) return listOf()
    if (start == end) return listOf(computeFibbonaciNumber(start))
    val output = mutableListOf(computeFibbonaciNumber(start), computeFibbonaciNumber(start + 1))
    (2..(end-start)).forEach { output.add(output[it-2] + output[it-1]) }
    return output
}

fun recursiveFibbonachi(previous: Int, current: Int, stepsLeft: Int): Int {
    if (stepsLeft < 0) return 1
    return when (stepsLeft) {
        0 -> current
        else -> recursiveFibbonachi(current, previous + current, stepsLeft - 1)
    }
}

fun computeNegativeFibbonachi(position:Int): Int {
    if (position >= 0) throw Exception("potition must be smaller than zero!")
    val resultIsNegative = position % 2 == 0
    val absoluteResult = computeFibbonaciNumber(-position)
    return if (resultIsNegative) (absoluteResult * -1) else absoluteResult
}

Compiled from "Fibbonaci.kt"
public final class com.gitTraining.FibbonaciKt {
  public static final int computeFibbonaciNumber(java.lang.Integer, boolean);
    Code:
       0: aload_0
       1: astore_2
       2: aload_2
       3: ifnonnull     11
       6: iconst_1
       7: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      10: astore_2
      11: iload_1
      12: ifeq          27
      15: iconst_1
      16: iconst_1
      17: aload_2
      18: invokevirtual #17                 // Method java/lang/Integer.intValue:()I
      21: iconst_2
      22: isub
      23: invokestatic  #21                 // Method recursiveFibbonachi:(III)I
      26: ireturn
      27: aload_2
      28: invokevirtual #17                 // Method java/lang/Integer.intValue:()I
      31: ifne          36
      34: iconst_0
      35: ireturn
      36: aload_2
      37: invokevirtual #17                 // Method java/lang/Integer.intValue:()I
      40: ifge          51
      43: aload_2
      44: invokevirtual #17                 // Method java/lang/Integer.intValue:()I
      47: invokestatic  #25                 // Method computeNegativeFibbonachi:(I)I
      50: ireturn
      51: aload_2
      52: iconst_1
      53: istore_3
      54: invokevirtual #17                 // Method java/lang/Integer.intValue:()I
      57: iload_3
      58: if_icmpeq     71
      61: aload_2
      62: iconst_2
      63: istore_3
      64: invokevirtual #17                 // Method java/lang/Integer.intValue:()I
      67: iload_3
      68: if_icmpne     73
      71: iconst_1
      72: ireturn
      73: iconst_1
      74: istore_3
      75: iconst_1
      76: istore        4
      78: iconst_2
      79: istore        5
      81: iload         5
      83: aload_2
      84: invokevirtual #17                 // Method java/lang/Integer.intValue:()I
      87: if_icmpge     109
      90: iload_3
      91: iload         4
      93: iadd
      94: istore        6
      96: iload         4
      98: istore_3
      99: iload         6
     101: istore        4
     103: iinc          5, 1
     106: goto          81
     109: iload         4
     111: ireturn

  public static int computeFibbonaciNumber$default(java.lang.Integer, boolean, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_2
       2: iand
       3: ifeq          8
       6: iconst_0
       7: istore_1
       8: aload_0
       9: iload_1
      10: invokestatic  #39                 // Method computeFibbonaciNumber:(Ljava/lang/Integer;Z)I
      13: ireturn

  public static final java.util.List<java.lang.Integer> computeFibbonachiArray(int, int, boolean);
    Code:
       0: iload_2
       1: ifne          117
       4: new           #45                 // class kotlin/ranges/IntRange
       7: dup
       8: iload_0
       9: iload_1
      10: invokespecial #49                 // Method kotlin/ranges/IntRange."<init>":(II)V
      13: checkcast     #51                 // class java/lang/Iterable
      16: astore_3
      17: iconst_0
      18: istore        4
      20: aload_3
      21: astore        5
      23: new           #53                 // class java/util/ArrayList
      26: dup
      27: aload_3
      28: bipush        10
      30: invokestatic  #59                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      33: invokespecial #62                 // Method java/util/ArrayList."<init>":(I)V
      36: checkcast     #64                 // class java/util/Collection
      39: astore        6
      41: iconst_0
      42: istore        7
      44: aload         5
      46: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      51: astore        8
      53: aload         8
      55: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      60: ifeq          110
      63: aload         8
      65: checkcast     #76                 // class kotlin/collections/IntIterator
      68: invokevirtual #79                 // Method kotlin/collections/IntIterator.nextInt:()I
      71: istore        9
      73: aload         6
      75: iload         9
      77: istore        10
      79: astore        12
      81: iconst_0
      82: istore        11
      84: iload         10
      86: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      89: iconst_0
      90: iconst_2
      91: aconst_null
      92: invokestatic  #81                 // Method computeFibbonaciNumber$default:(Ljava/lang/Integer;ZILjava/lang/Object;)I
      95: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      98: aload         12
     100: swap
     101: invokeinterface #85,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     106: pop
     107: goto          53
     110: aload         6
     112: checkcast     #87                 // class java/util/List
     115: nop
     116: areturn
     117: iload_0
     118: iload_1
     119: if_icmple     126
     122: invokestatic  #91                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     125: areturn
     126: iload_0
     127: iload_1
     128: if_icmpne     148
     131: iload_0
     132: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     135: iconst_0
     136: iconst_2
     137: aconst_null
     138: invokestatic  #81                 // Method computeFibbonaciNumber$default:(Ljava/lang/Integer;ZILjava/lang/Object;)I
     141: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     144: invokestatic  #95                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     147: areturn
     148: iconst_2
     149: anewarray     #9                  // class java/lang/Integer
     152: astore        4
     154: aload         4
     156: iconst_0
     157: iload_0
     158: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     161: iconst_0
     162: iconst_2
     163: aconst_null
     164: invokestatic  #81                 // Method computeFibbonaciNumber$default:(Ljava/lang/Integer;ZILjava/lang/Object;)I
     167: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     170: aastore
     171: aload         4
     173: iconst_1
     174: iload_0
     175: iconst_1
     176: iadd
     177: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     180: iconst_0
     181: iconst_2
     182: aconst_null
     183: invokestatic  #81                 // Method computeFibbonaciNumber$default:(Ljava/lang/Integer;ZILjava/lang/Object;)I
     186: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     189: aastore
     190: aload         4
     192: invokestatic  #99                 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
     195: astore_3
     196: new           #45                 // class kotlin/ranges/IntRange
     199: dup
     200: iconst_2
     201: iload_1
     202: iload_0
     203: isub
     204: invokespecial #49                 // Method kotlin/ranges/IntRange."<init>":(II)V
     207: checkcast     #51                 // class java/lang/Iterable
     210: astore        4
     212: iconst_0
     213: istore        5
     215: aload         4
     217: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     222: astore        6
     224: aload         6
     226: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     231: ifeq          298
     234: aload         6
     236: checkcast     #76                 // class kotlin/collections/IntIterator
     239: invokevirtual #79                 // Method kotlin/collections/IntIterator.nextInt:()I
     242: istore        7
     244: iload         7
     246: istore        8
     248: iconst_0
     249: istore        9
     251: aload_3
     252: aload_3
     253: iload         8
     255: iconst_2
     256: isub
     257: invokeinterface #103,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     262: checkcast     #105                // class java/lang/Number
     265: invokevirtual #106                // Method java/lang/Number.intValue:()I
     268: aload_3
     269: iload         8
     271: iconst_1
     272: isub
     273: invokeinterface #103,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     278: checkcast     #105                // class java/lang/Number
     281: invokevirtual #106                // Method java/lang/Number.intValue:()I
     284: iadd
     285: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     288: invokeinterface #107,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     293: pop
     294: nop
     295: goto          224
     298: nop
     299: aload_3
     300: areturn

  public static java.util.List computeFibbonachiArray$default(int, int, boolean, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_4
       2: iand
       3: ifeq          8
       6: iconst_0
       7: istore_2
       8: iload_0
       9: iload_1
      10: iload_2
      11: invokestatic  #130                // Method computeFibbonachiArray:(IIZ)Ljava/util/List;
      14: areturn

  public static final int recursiveFibbonachi(int, int, int);
    Code:
       0: iload_2
       1: ifge          6
       4: iconst_1
       5: ireturn
       6: iload_2
       7: ifne          14
      10: iload_1
      11: goto          24
      14: iload_1
      15: iload_0
      16: iload_1
      17: iadd
      18: iload_2
      19: iconst_1
      20: isub
      21: invokestatic  #21                 // Method recursiveFibbonachi:(III)I
      24: ireturn

  public static final int computeNegativeFibbonachi(int);
    Code:
       0: iload_0
       1: iflt          14
       4: new           #135                // class java/lang/Exception
       7: dup
       8: ldc           #137                // String potition must be smaller than zero!
      10: invokespecial #140                // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
      13: athrow
      14: iload_0
      15: iconst_2
      16: irem
      17: ifne          24
      20: iconst_1
      21: goto          25
      24: iconst_0
      25: istore_1
      26: iload_0
      27: ineg
      28: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      31: iconst_0
      32: iconst_2
      33: aconst_null
      34: invokestatic  #81                 // Method computeFibbonaciNumber$default:(Ljava/lang/Integer;ZILjava/lang/Object;)I
      37: istore_2
      38: iload_1
      39: ifeq          48
      42: iload_2
      43: iconst_m1
      44: imul
      45: goto          49
      48: iload_2
      49: ireturn
}


package bellman.graph

val INFINITE = Int.MAX_VALUE
val NO_EDGE = INFINITE

typealias AdjacencyMatrix = Array<IntArray>
typealias AdjacencyMatrix1D = IntArray
typealias AdjacencyList = Array<Adjacency>
typealias PlainAdjacencyList = IntArray
typealias Adjacency = Triple<Int, Int, Int>

data class InputGraph(val adjacencyMatrix: AdjacencyMatrix,
                      val sourceVertex: Int,
                      val vertexNumber: Int = adjacencyMatrix.size)

enum class PlainAdjacency(val number: Int) {
    SOURCE(0), DESTINATION(1), WEIGHT(2)

}

object Util {
    object AdjacencyUtil {
        val Adjacency.source: Int
            get() = this.first

        val Adjacency.destination: Int
            get() = this.second

        val Adjacency.weight: Int
            get() = this.third
    }

    object AdjacencyMatrixUtil {
        inline fun AdjacencyMatrix.vertexNumber() = this.size

        fun AdjacencyMatrix.toPlainAdjacencyList(): PlainAdjacencyList =
                this.mapIndexed { rowNum, row ->
                    row.mapIndexed { colNum, weight -> if (weight != INFINITE) intArrayOf(rowNum, colNum, weight) else null }
                            .filterNotNull()
                            .reduce { acc, ints -> acc + ints }
                }
                        .reduce { acc, list -> acc + list }

        fun AdjacencyMatrix.toAdjacencyList() = this.mapIndexed { row, ints ->
            ints.mapIndexed { col, w -> if (w != INFINITE) Triple(row, col, w) else null }
                    .filterNotNull()
        }
                .reduce { acc, list -> acc + list }
                .toTypedArray()
    }

    object PlainAdjacencyListUtil {
        inline operator fun PlainAdjacencyList.get(index: Int, col: Int) = this[3 * index + col]

        inline operator fun PlainAdjacencyList.get(index: Int, content: PlainAdjacency) = this[index, content.number]

        val PlainAdjacencyList.edgeNumber: Int
            get() = (this.size + 1) / 3
    }
}

Compiled from "util.kt"
public final class bellman.graph.Util$PlainAdjacencyListUtil {
  public static final bellman.graph.Util$PlainAdjacencyListUtil INSTANCE;

  private bellman.graph.Util$PlainAdjacencyListUtil();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int get(int[], int, int);
    Code:
       0: aload_1
       1: ldc           #15                 // String <this>
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore        4
       9: aload_1
      10: iconst_3
      11: iload_2
      12: imul
      13: iload_3
      14: iadd
      15: iaload
      16: ireturn

  public final int get(int[], int, bellman.graph.PlainAdjacency);
    Code:
       0: aload_1
       1: ldc           #15                 // String <this>
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_3
       7: ldc           #30                 // String content
       9: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iconst_0
      13: istore        4
      15: aload_0
      16: astore        5
      18: aload_1
      19: astore        6
      21: aload_3
      22: invokevirtual #36                 // Method bellman/graph/PlainAdjacency.getNumber:()I
      25: istore        7
      27: iconst_0
      28: istore        8
      30: aload         6
      32: iconst_3
      33: iload_2
      34: imul
      35: iload         7
      37: iadd
      38: iaload
      39: ireturn

  public final int getEdgeNumber(int[]);
    Code:
       0: aload_1
       1: ldc           #15                 // String <this>
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: arraylength
       8: iconst_1
       9: iadd
      10: iconst_3
      11: idiv
      12: ireturn

  static {};
    Code:
       0: new           #2                  // class bellman/graph/Util$PlainAdjacencyListUtil
       3: dup
       4: invokespecial #45                 // Method "<init>":()V
       7: putstatic     #48                 // Field INSTANCE:Lbellman/graph/Util$PlainAdjacencyListUtil;
      10: return
}

Compiled from "util.kt"
public final class bellman.graph.UtilKt {
  private static final int INFINITE;

  private static final int NO_EDGE;

  public static final int getINFINITE();
    Code:
       0: getstatic     #10                 // Field INFINITE:I
       3: ireturn

  public static final int getNO_EDGE();
    Code:
       0: getstatic     #14                 // Field NO_EDGE:I
       3: ireturn

  static {};
    Code:
       0: ldc           #17                 // int 2147483647
       2: putstatic     #10                 // Field INFINITE:I
       5: getstatic     #10                 // Field INFINITE:I
       8: putstatic     #14                 // Field NO_EDGE:I
      11: return
}

Compiled from "util.kt"
public final class bellman.graph.Util$AdjacencyMatrixUtil {
  public static final bellman.graph.Util$AdjacencyMatrixUtil INSTANCE;

  private bellman.graph.Util$AdjacencyMatrixUtil();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int vertexNumber(int[][]);
    Code:
       0: aload_1
       1: ldc           #15                 // String <this>
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_2
       8: aload_1
       9: checkcast     #23                 // class "[Ljava/lang/Object;"
      12: arraylength
      13: ireturn

  public final int[] toPlainAdjacencyList(int[][]);
    Code:
       0: aload_1
       1: ldc           #15                 // String <this>
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #23                 // class "[Ljava/lang/Object;"
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: astore        4
      16: new           #31                 // class java/util/ArrayList
      19: dup
      20: aload_2
      21: arraylength
      22: invokespecial #34                 // Method java/util/ArrayList."<init>":(I)V
      25: checkcast     #36                 // class java/util/Collection
      28: astore        5
      30: iconst_0
      31: istore        6
      33: iconst_0
      34: istore        7
      36: iconst_0
      37: istore        8
      39: aload         4
      41: arraylength
      42: istore        9
      44: iload         8
      46: iload         9
      48: if_icmpge     327
      51: aload         4
      53: iload         8
      55: aaload
      56: astore        10
      58: aload         5
      60: iload         7
      62: iinc          7, 1
      65: aload         10
      67: checkcast     #38                 // class "[I"
      70: astore        11
      72: istore        12
      74: astore        28
      76: iconst_0
      77: istore        13
      79: aload         11
      81: astore        14
      83: iconst_0
      84: istore        15
      86: aload         14
      88: astore        16
      90: new           #31                 // class java/util/ArrayList
      93: dup
      94: aload         14
      96: arraylength
      97: invokespecial #34                 // Method java/util/ArrayList."<init>":(I)V
     100: checkcast     #36                 // class java/util/Collection
     103: astore        17
     105: iconst_0
     106: istore        18
     108: iconst_0
     109: istore        19
     111: iconst_0
     112: istore        20
     114: aload         16
     116: arraylength
     117: istore        21
     119: iload         20
     121: iload         21
     123: if_icmpge     203
     126: aload         16
     128: iload         20
     130: iaload
     131: istore        22
     133: aload         17
     135: iload         19
     137: iinc          19, 1
     140: iload         22
     142: istore        23
     144: istore        24
     146: astore        25
     148: iconst_0
     149: istore        26
     151: iload         23
     153: invokestatic  #44                 // Method bellman/graph/UtilKt.getINFINITE:()I
     156: if_icmpeq     187
     159: iconst_3
     160: newarray       int
     162: astore        27
     164: aload         27
     166: iconst_0
     167: iload         12
     169: iastore
     170: aload         27
     172: iconst_1
     173: iload         24
     175: iastore
     176: aload         27
     178: iconst_2
     179: iload         23
     181: iastore
     182: aload         27
     184: goto          188
     187: aconst_null
     188: aload         25
     190: swap
     191: invokeinterface #48,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     196: pop
     197: iinc          20, 1
     200: goto          119
     203: aload         17
     205: checkcast     #50                 // class java/util/List
     208: nop
     209: checkcast     #52                 // class java/lang/Iterable
     212: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.filterNotNull:(Ljava/lang/Iterable;)Ljava/util/List;
     215: checkcast     #52                 // class java/lang/Iterable
     218: astore        14
     220: nop
     221: iconst_0
     222: istore        15
     224: aload         14
     226: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     231: astore        16
     233: aload         16
     235: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     240: ifne          253
     243: new           #70                 // class java/lang/UnsupportedOperationException
     246: dup
     247: ldc           #72                 // String Empty collection can\'t be reduced.
     249: invokespecial #75                 // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     252: athrow
     253: aload         16
     255: invokeinterface #79,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     260: astore        17
     262: aload         16
     264: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     269: ifeq          306
     272: aload         17
     274: aload         16
     276: invokeinterface #79,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     281: checkcast     #38                 // class "[I"
     284: astore        18
     286: checkcast     #38                 // class "[I"
     289: astore        19
     291: iconst_0
     292: istore        20
     294: aload         19
     296: aload         18
     298: invokestatic  #85                 // Method kotlin/collections/ArraysKt.plus:([I[I)[I
     301: astore        17
     303: goto          262
     306: aload         17
     308: checkcast     #38                 // class "[I"
     311: nop
     312: aload         28
     314: swap
     315: invokeinterface #48,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     320: pop
     321: iinc          8, 1
     324: goto          44
     327: aload         5
     329: checkcast     #50                 // class java/util/List
     332: nop
     333: checkcast     #52                 // class java/lang/Iterable
     336: astore_2
     337: nop
     338: iconst_0
     339: istore_3
     340: aload_2
     341: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     346: astore        4
     348: aload         4
     350: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     355: ifne          368
     358: new           #70                 // class java/lang/UnsupportedOperationException
     361: dup
     362: ldc           #72                 // String Empty collection can\'t be reduced.
     364: invokespecial #75                 // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     367: athrow
     368: aload         4
     370: invokeinterface #79,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     375: astore        5
     377: aload         4
     379: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     384: ifeq          421
     387: aload         5
     389: aload         4
     391: invokeinterface #79,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     396: checkcast     #38                 // class "[I"
     399: astore        6
     401: checkcast     #38                 // class "[I"
     404: astore        7
     406: iconst_0
     407: istore        8
     409: aload         7
     411: aload         6
     413: invokestatic  #85                 // Method kotlin/collections/ArraysKt.plus:([I[I)[I
     416: astore        5
     418: goto          377
     421: aload         5
     423: checkcast     #38                 // class "[I"
     426: areturn

  public final kotlin.Triple<java.lang.Integer, java.lang.Integer, java.lang.Integer>[] toAdjacencyList(int[][]);
    Code:
       0: aload_1
       1: ldc           #15                 // String <this>
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #23                 // class "[Ljava/lang/Object;"
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: astore        4
      16: new           #31                 // class java/util/ArrayList
      19: dup
      20: aload_2
      21: arraylength
      22: invokespecial #34                 // Method java/util/ArrayList."<init>":(I)V
      25: checkcast     #36                 // class java/util/Collection
      28: astore        5
      30: iconst_0
      31: istore        6
      33: iconst_0
      34: istore        7
      36: iconst_0
      37: istore        8
      39: aload         4
      41: arraylength
      42: istore        9
      44: iload         8
      46: iload         9
      48: if_icmpge     227
      51: aload         4
      53: iload         8
      55: aaload
      56: astore        10
      58: aload         5
      60: iload         7
      62: iinc          7, 1
      65: aload         10
      67: checkcast     #38                 // class "[I"
      70: astore        11
      72: istore        12
      74: astore        27
      76: iconst_0
      77: istore        13
      79: aload         11
      81: astore        14
      83: iconst_0
      84: istore        15
      86: aload         14
      88: astore        16
      90: new           #31                 // class java/util/ArrayList
      93: dup
      94: aload         14
      96: arraylength
      97: invokespecial #34                 // Method java/util/ArrayList."<init>":(I)V
     100: checkcast     #36                 // class java/util/Collection
     103: astore        17
     105: iconst_0
     106: istore        18
     108: iconst_0
     109: istore        19
     111: iconst_0
     112: istore        20
     114: aload         16
     116: arraylength
     117: istore        21
     119: iload         20
     121: iload         21
     123: if_icmpge     200
     126: aload         16
     128: iload         20
     130: iaload
     131: istore        22
     133: aload         17
     135: iload         19
     137: iinc          19, 1
     140: iload         22
     142: istore        23
     144: istore        24
     146: astore        25
     148: iconst_0
     149: istore        26
     151: iload         23
     153: invokestatic  #44                 // Method bellman/graph/UtilKt.getINFINITE:()I
     156: if_icmpeq     184
     159: new           #118                // class kotlin/Triple
     162: dup
     163: iload         12
     165: invokestatic  #124                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     168: iload         24
     170: invokestatic  #124                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     173: iload         23
     175: invokestatic  #124                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     178: invokespecial #127                // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
     181: goto          185
     184: aconst_null
     185: aload         25
     187: swap
     188: invokeinterface #48,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     193: pop
     194: iinc          20, 1
     197: goto          119
     200: aload         17
     202: checkcast     #50                 // class java/util/List
     205: nop
     206: checkcast     #52                 // class java/lang/Iterable
     209: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.filterNotNull:(Ljava/lang/Iterable;)Ljava/util/List;
     212: aload         27
     214: swap
     215: invokeinterface #48,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     220: pop
     221: iinc          8, 1
     224: goto          44
     227: aload         5
     229: checkcast     #50                 // class java/util/List
     232: nop
     233: checkcast     #52                 // class java/lang/Iterable
     236: astore_2
     237: nop
     238: iconst_0
     239: istore_3
     240: aload_2
     241: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     246: astore        4
     248: aload         4
     250: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     255: ifne          268
     258: new           #70                 // class java/lang/UnsupportedOperationException
     261: dup
     262: ldc           #72                 // String Empty collection can\'t be reduced.
     264: invokespecial #75                 // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     267: athrow
     268: aload         4
     270: invokeinterface #79,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     275: astore        5
     277: aload         4
     279: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     284: ifeq          327
     287: aload         5
     289: aload         4
     291: invokeinterface #79,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     296: checkcast     #50                 // class java/util/List
     299: astore        6
     301: checkcast     #50                 // class java/util/List
     304: astore        7
     306: iconst_0
     307: istore        8
     309: aload         7
     311: checkcast     #36                 // class java/util/Collection
     314: aload         6
     316: checkcast     #52                 // class java/lang/Iterable
     319: invokestatic  #130                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     322: astore        5
     324: goto          277
     327: aload         5
     329: checkcast     #36                 // class java/util/Collection
     332: astore_2
     333: nop
     334: iconst_0
     335: istore_3
     336: aload_2
     337: astore        4
     339: aload         4
     341: iconst_0
     342: anewarray     #118                // class kotlin/Triple
     345: invokeinterface #134,  2          // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     350: checkcast     #136                // class "[Lkotlin/Triple;"
     353: areturn

  static {};
    Code:
       0: new           #2                  // class bellman/graph/Util$AdjacencyMatrixUtil
       3: dup
       4: invokespecial #148                // Method "<init>":()V
       7: putstatic     #151                // Field INSTANCE:Lbellman/graph/Util$AdjacencyMatrixUtil;
      10: return
}

Compiled from "util.kt"
public final class bellman.graph.Util {
  public static final bellman.graph.Util INSTANCE;

  private bellman.graph.Util();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  static {};
    Code:
       0: new           #2                  // class bellman/graph/Util
       3: dup
       4: invokespecial #12                 // Method "<init>":()V
       7: putstatic     #15                 // Field INSTANCE:Lbellman/graph/Util;
      10: return
}

Compiled from "util.kt"
public final class bellman.graph.Util$AdjacencyUtil {
  public static final bellman.graph.Util$AdjacencyUtil INSTANCE;

  private bellman.graph.Util$AdjacencyUtil();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int getSource(kotlin.Triple<java.lang.Integer, java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_1
       1: ldc           #16                 // String <this>
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokevirtual #28                 // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
      10: checkcast     #30                 // class java/lang/Number
      13: invokevirtual #34                 // Method java/lang/Number.intValue:()I
      16: ireturn

  public final int getDestination(kotlin.Triple<java.lang.Integer, java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_1
       1: ldc           #16                 // String <this>
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokevirtual #40                 // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
      10: checkcast     #30                 // class java/lang/Number
      13: invokevirtual #34                 // Method java/lang/Number.intValue:()I
      16: ireturn

  public final int getWeight(kotlin.Triple<java.lang.Integer, java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_1
       1: ldc           #16                 // String <this>
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokevirtual #45                 // Method kotlin/Triple.getThird:()Ljava/lang/Object;
      10: checkcast     #30                 // class java/lang/Number
      13: invokevirtual #34                 // Method java/lang/Number.intValue:()I
      16: ireturn

  static {};
    Code:
       0: new           #2                  // class bellman/graph/Util$AdjacencyUtil
       3: dup
       4: invokespecial #48                 // Method "<init>":()V
       7: putstatic     #51                 // Field INSTANCE:Lbellman/graph/Util$AdjacencyUtil;
      10: return
}


package bellman.graph.algorithm

import bellman.graph.INFINITE
import bellman.graph.InputGraph
import bellman.graph.PlainAdjacency
import bellman.graph.PlainAdjacencyList
import bellman.graph.Util.AdjacencyMatrixUtil.toPlainAdjacencyList
import bellman.graph.Util.PlainAdjacencyListUtil.edgeNumber
import bellman.graph.Util.PlainAdjacencyListUtil.get

fun bellmanFord(graph: InputGraph) = with(graph) {
    bellmanFord(
            adjacencyMatrix.toPlainAdjacencyList(),
            sourceVertex,
            vertexNumber)
}

fun bellmanFord(plainAdjacencyList: PlainAdjacencyList,
                sourceVertex: Int,
                vertexNumber: Int): IntArray =
        IntArray(vertexNumber, { INFINITE })
                .apply { this[sourceVertex] = 0 }
                .apply { while (plainAdjacencyList.relaxAll(this)); }

//TODO:Need optimization
fun PlainAdjacencyList.relaxAll(distance: IntArray, from: Int = 0, to: Int = edgeNumber - 1) =
        (from..to)
                .map { relax(it, distance) }
                .onEach { if (it) return@relaxAll true }
                .let { false }

fun PlainAdjacencyList.relax(index: Int, distance: IntArray): Boolean {
    val lastValue = distance[get(index, PlainAdjacency.DESTINATION)]

    if (distance[get(index, PlainAdjacency.SOURCE)] < INFINITE) {
        distance[get(index, PlainAdjacency.DESTINATION)] =
                minOf(distance[get(index, PlainAdjacency.DESTINATION)].toLong(),
                        distance[get(index, PlainAdjacency.SOURCE)].toLong()
                                + get(index, PlainAdjacency.WEIGHT))
                        .toInt()
    }

    val isRelaxed = lastValue != distance[get(index, PlainAdjacency.DESTINATION)]

    return isRelaxed
}

Compiled from "plainBellmanFord.kt"
public final class bellman.graph.algorithm.PlainBellmanFordKt {
  public static final int[] bellmanFord(bellman.graph.InputGraph);
    Code:
       0: aload_0
       1: ldc           #9                  // String graph
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: astore_1
       8: iconst_0
       9: istore_2
      10: getstatic     #21                 // Field bellman/graph/Util$AdjacencyMatrixUtil.INSTANCE:Lbellman/graph/Util$AdjacencyMatrixUtil;
      13: aload_1
      14: invokevirtual #27                 // Method bellman/graph/InputGraph.getAdjacencyMatrix:()[[I
      17: invokevirtual #31                 // Method bellman/graph/Util$AdjacencyMatrixUtil.toPlainAdjacencyList:([[I)[I
      20: aload_1
      21: invokevirtual #35                 // Method bellman/graph/InputGraph.getSourceVertex:()I
      24: aload_1
      25: invokevirtual #38                 // Method bellman/graph/InputGraph.getVertexNumber:()I
      28: invokestatic  #41                 // Method bellmanFord:([III)[I
      31: nop
      32: nop
      33: areturn

  public static final int[] bellmanFord(int[], int, int);
    Code:
       0: aload_0
       1: ldc           #47                 // String plainAdjacencyList
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_3
       8: iload_2
       9: newarray       int
      11: astore        4
      13: iload_3
      14: iload_2
      15: if_icmpge     35
      18: iload_3
      19: istore        5
      21: aload         4
      23: iload         5
      25: invokestatic  #52                 // Method bellman/graph/UtilKt.getINFINITE:()I
      28: iastore
      29: iinc          3, 1
      32: goto          13
      35: aload         4
      37: astore_3
      38: aload_3
      39: astore        4
      41: iconst_0
      42: istore        5
      44: aload         4
      46: iload_1
      47: iconst_0
      48: iastore
      49: aload_3
      50: astore_3
      51: aload_3
      52: astore        4
      54: iconst_0
      55: istore        5
      57: aload_0
      58: aload         4
      60: iconst_0
      61: iconst_0
      62: bipush        6
      64: aconst_null
      65: invokestatic  #56                 // Method relaxAll$default:([I[IIIILjava/lang/Object;)Z
      68: ifeq          74
      71: goto          57
      74: aload_3
      75: areturn

  public static final boolean relaxAll(int[], int[], int, int);
    Code:
       0: aload_0
       1: ldc           #68                 // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #70                 // String distance
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: new           #72                 // class kotlin/ranges/IntRange
      15: dup
      16: iload_2
      17: iload_3
      18: invokespecial #76                 // Method kotlin/ranges/IntRange."<init>":(II)V
      21: checkcast     #78                 // class java/lang/Iterable
      24: astore        4
      26: nop
      27: iconst_0
      28: istore        5
      30: aload         4
      32: astore        6
      34: new           #80                 // class java/util/ArrayList
      37: dup
      38: aload         4
      40: bipush        10
      42: invokestatic  #86                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      45: invokespecial #89                 // Method java/util/ArrayList."<init>":(I)V
      48: checkcast     #91                 // class java/util/Collection
      51: astore        7
      53: iconst_0
      54: istore        8
      56: aload         6
      58: invokeinterface #95,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      63: astore        9
      65: aload         9
      67: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      72: ifeq          118
      75: aload         9
      77: checkcast     #103                // class kotlin/collections/IntIterator
      80: invokevirtual #106                // Method kotlin/collections/IntIterator.nextInt:()I
      83: istore        10
      85: aload         7
      87: iload         10
      89: istore        11
      91: astore        13
      93: iconst_0
      94: istore        12
      96: aload_0
      97: iload         11
      99: aload_1
     100: invokestatic  #110                // Method relax:([II[I)Z
     103: invokestatic  #116                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     106: aload         13
     108: swap
     109: invokeinterface #120,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     114: pop
     115: goto          65
     118: aload         7
     120: checkcast     #122                // class java/util/List
     123: nop
     124: checkcast     #78                 // class java/lang/Iterable
     127: astore        4
     129: nop
     130: iconst_0
     131: istore        5
     133: aload         4
     135: astore        6
     137: aload         6
     139: astore        7
     141: iconst_0
     142: istore        8
     144: aload         7
     146: invokeinterface #95,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     151: astore        9
     153: aload         9
     155: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     160: ifeq          196
     163: aload         9
     165: invokeinterface #126,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     170: astore        10
     172: aload         10
     174: checkcast     #112                // class java/lang/Boolean
     177: invokevirtual #129                // Method java/lang/Boolean.booleanValue:()Z
     180: istore        11
     182: iconst_0
     183: istore        12
     185: iload         11
     187: ifeq          192
     190: iconst_1
     191: ireturn
     192: nop
     193: goto          153
     196: aload         6
     198: nop
     199: checkcast     #122                // class java/util/List
     202: astore        5
     204: iconst_0
     205: istore        6
     207: iconst_0
     208: nop
     209: ireturn

  public static boolean relaxAll$default(int[], int[], int, int, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_2
       3: iand
       4: ifeq          9
       7: iconst_0
       8: istore_2
       9: iload         4
      11: iconst_4
      12: iand
      13: ifeq          26
      16: getstatic     #157                // Field bellman/graph/Util$PlainAdjacencyListUtil.INSTANCE:Lbellman/graph/Util$PlainAdjacencyListUtil;
      19: aload_0
      20: invokevirtual #161                // Method bellman/graph/Util$PlainAdjacencyListUtil.getEdgeNumber:([I)I
      23: iconst_1
      24: isub
      25: istore_3
      26: aload_0
      27: aload_1
      28: iload_2
      29: iload_3
      30: invokestatic  #163                // Method relaxAll:([I[III)Z
      33: ireturn

  public static final boolean relax(int[], int, int[]);
    Code:
       0: aload_0
       1: ldc           #68                 // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #70                 // String distance
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: getstatic     #157                // Field bellman/graph/Util$PlainAdjacencyListUtil.INSTANCE:Lbellman/graph/Util$PlainAdjacencyListUtil;
      16: astore        4
      18: aload_0
      19: astore        5
      21: getstatic     #169                // Field bellman/graph/PlainAdjacency.DESTINATION:Lbellman/graph/PlainAdjacency;
      24: astore        6
      26: iconst_0
      27: istore        7
      29: aload         4
      31: astore        8
      33: aload         5
      35: astore        9
      37: aload         6
      39: invokevirtual #172                // Method bellman/graph/PlainAdjacency.getNumber:()I
      42: istore        10
      44: iconst_0
      45: istore        11
      47: aload         9
      49: iconst_3
      50: iload_1
      51: imul
      52: iload         10
      54: iadd
      55: iaload
      56: nop
      57: iaload
      58: istore_3
      59: aload_2
      60: getstatic     #157                // Field bellman/graph/Util$PlainAdjacencyListUtil.INSTANCE:Lbellman/graph/Util$PlainAdjacencyListUtil;
      63: astore        4
      65: aload_0
      66: astore        5
      68: getstatic     #175                // Field bellman/graph/PlainAdjacency.SOURCE:Lbellman/graph/PlainAdjacency;
      71: astore        6
      73: iconst_0
      74: istore        7
      76: aload         4
      78: astore        8
      80: aload         5
      82: astore        9
      84: aload         6
      86: invokevirtual #172                // Method bellman/graph/PlainAdjacency.getNumber:()I
      89: istore        10
      91: iconst_0
      92: istore        11
      94: aload         9
      96: iconst_3
      97: iload_1
      98: imul
      99: iload         10
     101: iadd
     102: iaload
     103: nop
     104: iaload
     105: invokestatic  #52                 // Method bellman/graph/UtilKt.getINFINITE:()I
     108: if_icmpge     309
     111: aload_2
     112: getstatic     #157                // Field bellman/graph/Util$PlainAdjacencyListUtil.INSTANCE:Lbellman/graph/Util$PlainAdjacencyListUtil;
     115: astore        4
     117: aload_0
     118: astore        5
     120: getstatic     #169                // Field bellman/graph/PlainAdjacency.DESTINATION:Lbellman/graph/PlainAdjacency;
     123: astore        6
     125: iconst_0
     126: istore        7
     128: aload         4
     130: astore        8
     132: aload         5
     134: astore        9
     136: aload         6
     138: invokevirtual #172                // Method bellman/graph/PlainAdjacency.getNumber:()I
     141: istore        10
     143: iconst_0
     144: istore        11
     146: aload         9
     148: iconst_3
     149: iload_1
     150: imul
     151: iload         10
     153: iadd
     154: iaload
     155: nop
     156: aload_2
     157: getstatic     #157                // Field bellman/graph/Util$PlainAdjacencyListUtil.INSTANCE:Lbellman/graph/Util$PlainAdjacencyListUtil;
     160: astore        4
     162: aload_0
     163: astore        5
     165: getstatic     #169                // Field bellman/graph/PlainAdjacency.DESTINATION:Lbellman/graph/PlainAdjacency;
     168: astore        6
     170: iconst_0
     171: istore        7
     173: aload         4
     175: astore        8
     177: aload         5
     179: astore        9
     181: aload         6
     183: invokevirtual #172                // Method bellman/graph/PlainAdjacency.getNumber:()I
     186: istore        10
     188: iconst_0
     189: istore        11
     191: aload         9
     193: iconst_3
     194: iload_1
     195: imul
     196: iload         10
     198: iadd
     199: iaload
     200: nop
     201: iaload
     202: i2l
     203: lstore        4
     205: aload_2
     206: getstatic     #157                // Field bellman/graph/Util$PlainAdjacencyListUtil.INSTANCE:Lbellman/graph/Util$PlainAdjacencyListUtil;
     209: astore        6
     211: aload_0
     212: astore        7
     214: getstatic     #175                // Field bellman/graph/PlainAdjacency.SOURCE:Lbellman/graph/PlainAdjacency;
     217: astore        8
     219: iconst_0
     220: istore        9
     222: aload         6
     224: astore        10
     226: aload         7
     228: astore        11
     230: aload         8
     232: invokevirtual #172                // Method bellman/graph/PlainAdjacency.getNumber:()I
     235: istore        12
     237: iconst_0
     238: istore        13
     240: aload         11
     242: iconst_3
     243: iload_1
     244: imul
     245: iload         12
     247: iadd
     248: iaload
     249: nop
     250: iaload
     251: i2l
     252: getstatic     #157                // Field bellman/graph/Util$PlainAdjacencyListUtil.INSTANCE:Lbellman/graph/Util$PlainAdjacencyListUtil;
     255: astore        6
     257: aload_0
     258: astore        7
     260: getstatic     #178                // Field bellman/graph/PlainAdjacency.WEIGHT:Lbellman/graph/PlainAdjacency;
     263: astore        8
     265: iconst_0
     266: istore        9
     268: aload         6
     270: astore        10
     272: aload         7
     274: astore        11
     276: aload         8
     278: invokevirtual #172                // Method bellman/graph/PlainAdjacency.getNumber:()I
     281: istore        12
     283: iconst_0
     284: istore        13
     286: aload         11
     288: iconst_3
     289: iload_1
     290: imul
     291: iload         12
     293: iadd
     294: iaload
     295: nop
     296: i2l
     297: ladd
     298: lstore        6
     300: lload         4
     302: lload         6
     304: invokestatic  #184                // Method java/lang/Math.min:(JJ)J
     307: l2i
     308: iastore
     309: iload_3
     310: aload_2
     311: getstatic     #157                // Field bellman/graph/Util$PlainAdjacencyListUtil.INSTANCE:Lbellman/graph/Util$PlainAdjacencyListUtil;
     314: astore        5
     316: aload_0
     317: astore        6
     319: getstatic     #169                // Field bellman/graph/PlainAdjacency.DESTINATION:Lbellman/graph/PlainAdjacency;
     322: astore        7
     324: iconst_0
     325: istore        8
     327: aload         5
     329: astore        9
     331: aload         6
     333: astore        10
     335: aload         7
     337: invokevirtual #172                // Method bellman/graph/PlainAdjacency.getNumber:()I
     340: istore        11
     342: iconst_0
     343: istore        12
     345: aload         10
     347: iconst_3
     348: iload_1
     349: imul
     350: iload         11
     352: iadd
     353: iaload
     354: nop
     355: iaload
     356: if_icmpeq     363
     359: iconst_1
     360: goto          364
     363: iconst_0
     364: istore        4
     366: iload         4
     368: ireturn
}