Giter VIP home page Giter VIP logo

datastructs_and_algorithm's Issues

并查集处理错误

在kruscal 算法当中 博客写的是 “终点”这个不好理解的概念 其实完全是博主坑爹自己创造的判断条件,此处应该使用并查集来确定是否成环。

在代码中 博主写的是 vends[m]=n; 这个语句也不符合博主 ”终点“ 的定义,应该先判断m,n大小
if(m<n) swap(m,n)
vends[m]=n;
否则会造成一个边重复出现的错误 下面是出现错误的测试用例: (出现了(0,1) (1,0))
int[] graph0 = new int[]{0, 10, MAX_WEIGHT, MAX_WEIGHT, MAX_WEIGHT, 11, MAX_WEIGHT, MAX_WEIGHT, MAX_WEIGHT};
int[] graph1 = new int[]{10, 0, 18, MAX_WEIGHT, MAX_WEIGHT, MAX_WEIGHT, 16, MAX_WEIGHT, 12};
int[] graph2 = new int[]{MAX_WEIGHT, 18, 0, 22, MAX_WEIGHT, MAX_WEIGHT, MAX_WEIGHT, MAX_WEIGHT, 8};
int[] graph3 = new int[]{MAX_WEIGHT, MAX_WEIGHT, 22, 0, 20, MAX_WEIGHT, MAX_WEIGHT, 16, 21};
int[] graph4 = new int[]{MAX_WEIGHT, MAX_WEIGHT, MAX_WEIGHT, 20, 0, 26, MAX_WEIGHT, 7, MAX_WEIGHT};
int[] graph5 = new int[]{11, MAX_WEIGHT, MAX_WEIGHT, MAX_WEIGHT, 26, 0, 17, MAX_WEIGHT, MAX_WEIGHT};
int[] graph6 = new int[]{MAX_WEIGHT, 16, MAX_WEIGHT, MAX_WEIGHT, MAX_WEIGHT, 17, 0, 19, MAX_WEIGHT};
int[] graph7 = new int[]{MAX_WEIGHT, MAX_WEIGHT, MAX_WEIGHT, 16, 7, MAX_WEIGHT, 19, 0, MAX_WEIGHT};
int[] graph8 = new int[]{MAX_WEIGHT, 12, 8, 21, MAX_WEIGHT, MAX_WEIGHT, MAX_WEIGHT, MAX_WEIGHT, 0};

    graph.matrix[0] = graph0;
    graph.matrix[1] = graph1;
    graph.matrix[2] = graph2;
    graph.matrix[3] = graph3;
    graph.matrix[4] = graph4;
    graph.matrix[5] = graph5;
    graph.matrix[6] = graph6;
    graph.matrix[7] = graph7;
    graph.matrix[8] = graph8;

Kruskal 算法中保存每个结点终点的数组大小初始化错误

int[] vends = new int[mEdgNum]; // 用于保存"已有最小生成树"中每个顶点在该最小树中的终点。

此数组初始化大小应该为顶点个数,而非边条数,因为在无向连通图中,边的条数最小可以为顶点个数减一(此时该无向连通图就是一棵树),故当一个无向连通图本身就是一棵树时,获取索引最大的顶点的终点,会有数组越界的异常。

c语言版本的BFS

first_vertexnext_vertix找的节点有个条件:应该是没有被访问过的节点

建议

遍历过的线是不是可以考虑擦除(set边为0)?

请问一下

请问一下博主是用什么主题搭建的?非常喜欢那种目录的样式

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.