Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 826531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:25:44+00:00 2026-05-15T03:25:44+00:00

i cannot understand a certain part of the paper published by Donald Johnson about

  • 0

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 matrix Ak which is mentioned in the following line of the pseudo code :

Ak:=adjacency structure of strong component K with least
vertex in subgraph of G induced by {s,s+1,….n};

to make things worse some lines after is mentins ” for i in Vk do ” without declaring what the Vk is…

As far i have understand we have the following:
1) in general, a strong component is a sub-graph of a graph, in which for every node of this sub-graph there is a path to any node of the sub-graph (in other words you can access any node of the sub-graph from any other node of the sub-graph)

2) a sub-graph induced by a list of nodes is
a graph containing all these nodes plus all the edges connecting these nodes.
in paper the mathematical definition is ” F is a subgraph of G induced by W if W is subset of V and F = (W,{u,y)|u,y in W and (u,y) in E)}) where u,y are edges , E is the set of all the edges in the graph, W is a set of nodes.

3)in the code implementation the nodes are named by integer numbers 1 … n.

4) I suspect that the Vk is the set of nodes of the strong component K.

now to the question. Lets say we have a graph G= (V,E) with V = {1,2,3,4,5,6,7,8,9} which it can be divided into 3 strong components the SC1 = {1,4,7,8} SC2= {2,3,9} SC3 = {5,6} (and their edges)

Can anybody give me an example for s =1, s= 2, s= 5 what if going to be the Vk and Ak according to the code?

The pseudo code is in my previous question in
Understanding the pseudocode in the Donald B. Johnson's algorithm

and the paper can be found at
Understanding the pseudocode in the Donald B. Johnson's algorithm

thank you in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:25:45+00:00Added an answer on May 15, 2026 at 3:25 am

    It works! In an earlier iteration of the Johnson algorithm, I had supposed that A was an adjacency matrix. Instead, it appears to represent an adjacency list. In that example, implemented below, the vertices {a, b, c} are numbered {0, 1, 2}, yielding the following circuits.

    Addendum: As noted in this proposed edit and helpful answer, the algorithm specifies that unblock() should remove the element having the value w, not the element having the index w.

    list.remove(Integer.valueOf(w));
    

    Sample output:

    0 1 0
    0 1 2 0
    0 2 0
    0 2 1 0
    1 0 1
    1 0 2 1
    1 2 0 1
    1 2 1
    2 0 1 2
    2 0 2
    2 1 0 2
    2 1 2
    

    By default, the program starts with s = 0; implementing s := least vertex in V as an optimization remains. A variation that produces only unique cycles is shown here.

    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.List;
    import java.util.Stack;
    
    /**
     * @see http://dutta.csc.ncsu.edu/csc791_spring07/wrap/circuits_johnson.pdf
     * @see https://stackoverflow.com/questions/2908575
     * @see https://stackoverflow.com/questions/2939877
     * @see http://en.wikipedia.org/wiki/Adjacency_matrix
     * @see http://en.wikipedia.org/wiki/Adjacency_list
     */
    public final class CircuitFinding {
    
        final Stack<Integer> stack = new Stack<Integer>();
        final List<List<Integer>> a;
        final List<List<Integer>> b;
        final boolean[] blocked;
        final int n;
        int s;
    
        public static void main(String[] args) {
            List<List<Integer>> a = new ArrayList<List<Integer>>();
            a.add(new ArrayList<Integer>(Arrays.asList(1, 2)));
            a.add(new ArrayList<Integer>(Arrays.asList(0, 2)));
            a.add(new ArrayList<Integer>(Arrays.asList(0, 1)));
            CircuitFinding cf = new CircuitFinding(a);
            cf.find();
        }
    
        /**
         * @param a adjacency structure of strong component K with
         * least vertex in subgraph of G induced by {s, s + 1, n};
         */
        public CircuitFinding(List<List<Integer>> a) {
            this.a = a;
            n = a.size();
            blocked = new boolean[n];
            b = new ArrayList<List<Integer>>();
            for (int i = 0; i < n; i++) {
                b.add(new ArrayList<Integer>());
            }
        }
    
        private void unblock(int u) {
            blocked[u] = false;
            List<Integer> list = b.get(u);
            for (int w : list) {
                //delete w from B(u);
                list.remove(Integer.valueOf(w));
                if (blocked[w]) {
                    unblock(w);
                }
            }
        }
    
        private boolean circuit(int v) {
            boolean f = false;
            stack.push(v);
            blocked[v] = true;
            L1:
            for (int w : a.get(v)) {
                if (w == s) {
                    //output circuit composed of stack followed by s;
                    for (int i : stack) {
                        System.out.print(i + " ");
                    }
                    System.out.println(s);
                    f = true;
                } else if (!blocked[w]) {
                    if (circuit(w)) {
                        f = true;
                    }
                }
            }
            L2:
            if (f) {
                unblock(v);
            } else {
                for (int w : a.get(v)) {
                    //if (v∉B(w)) put v on B(w);
                    if (!b.get(w).contains(v)) {
                        b.get(w).add(v);
                    }
                }
            }
            v = stack.pop();
            return f;
        }
    
        public void find() {
            while (s < n) {
                if (a != null) {
                    //s := least vertex in V;
                    L3:
                    circuit(s);
                    s++;
                } else {
                    s = n;
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking at jquery resize plugin and can't understand certain things about how it
I cannot seem to understand why when working with certain values the JProgressBar will
I cannot understand the Oracle documentation. :-( Does anybody know how to fetch multiple
I cannot understand how this is possible. Please help!! I have an app with
I cannot understand the calculation 66 ⊕ fa = 9c. The sum is clearly
I cannot understand how Bing Community site is implemented. Clicking one of the All
I cannot understand why the code below is giving me this error in firebug
I cannot understand the Java memory usage. I have an application which is executed
I cannot understand why this throws undefined reference to `floor' : double curr_time =
I cannot understand why I am getting deadlock in this simple sample.What is wrong

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.