help in the Donalds B. Johnson's algorithm, i cannot understand the pseudo code (PART II)

前端 未结 4 1240
后悔当初
后悔当初 2020-11-29 11:50

i cannot understand a certain part of the paper published by Donald Johnson about finding cycles (Circuits) in a graph.

More specific i cannot understand what is the

4条回答
  •  天命终不由人
    2020-11-29 12:25

    I had sumbitted an edit request to @trashgod's code to fix the exception thrown in unblock(). Essentially, the algorithm states that the element w (which is not an index) is to be removed from the list. The code above used list.remove(w), which treats w as an index.

    My edit request was rejected! Not sure why, because I have tested the above with my modification on a network of 20,000 nodes and 70,000 edges and it doesn't crash.

    I have also modified Johnson's algorithm to be more adapted to undirected graphs. If anybody wants these modifications please contact me.

    Below is my code for unblock().

    private void unblock(int u) {
        blocked[u] = false;
        List list = b.get(u);
        int w;
        for (int iw=0; iw < list.size(); iw++) {
            w = Integer.valueOf(list.get(iw));
            //delete w from B(u);
            list.remove(iw);
            if (blocked[w]) {
                unblock(w);
            }
        }
    }
    

提交回复
热议问题