克鲁斯卡尔算法

2020-12-13 15:32

阅读:519

标签:ram   ext   lca   getter   结构   weight   dex   vat   case   

问题描述

public class KrusKalCase {


    public static void main(String[] args) {
        String[] data = {"A", "B", "C", "D", "E", "F", "G"};
        int[][] edges = new int[data.length][data.length];
        for (int[] edge : edges) {
            for (int i = 0; i  krusKalCase(AdjacentMatrix adjacentMatrix) {
        // 获取顶点集合
        String[] data = adjacentMatrix.getData();
        // 获取邻接矩阵
        int[][] edges = adjacentMatrix.getEdges();
        //optimalPatnList
        List optimalPathList = new ArrayList();
        // 获取所有的路径
        List allPath = new ArrayList();
        for (int i = 0; i  0) {
                    allPath.add(new PathData().setStart(data[i]).setEnd(data[j]).setWeight(edges[i][j]));
                }
            }
        }
        // 从小到大排序(冒泡排序)
        for (int i = 0; i  next.getWeight()) {
                    allPath.set(j, next);
                    allPath.set(j + 1, current);
                }
            }
        }

        for (int i = 0; i  权值:" + weight;
    }
}

克鲁斯卡尔算法

标签:ram   ext   lca   getter   结构   weight   dex   vat   case   

原文地址:https://www.cnblogs.com/MND1024/p/11611603.html


评论


亲,登录后才可以留言!