Trying to run the java implementation of Tarjan algorithm

1.2k views Asked by At

I am trying to run the Tarjan java implementation from wikipedia. My final goal is to inject a few println at specifc points, this will allow me to understand further the code.

What have I done so far

  • I copy pasted these 3 source codes

a)Tarjan source code b)Edge source code c)Node source code j in 3 separate files under in the same folder.

  • I was able to run a helloworld example (unfortunatley my java background is almost zero, last time I coded java was for homework, years agao).

What is the concrete problem I am facing I get 3 erros:

Tarjan.java:9: error: cannot find symbol
  public ArrayList<ArrayList<Node>> executeTarjan(AdjacencyList graph){
                                                  ^
  symbol:   class AdjacencyList
  location: class Tarjan
Tarjan.java:28: error: cannot find symbol
   private ArrayList<ArrayList<Node>> tarjan(Node v, AdjacencyList list){
                                                     ^
  symbol:   class AdjacencyList
  location: class Tarjan
Tarjan.java:14: error: cannot find symbol
          List<Node> nodeList = new ArrayList<Node>(graph.getSourceNodeSet());
          ^
  symbol:   class List
  location: class Tarjan
3 errors

The corresponding lines: 9, 28, 14 are these

//line 9
 public ArrayList<ArrayList<Node>> executeTarjan(AdjacencyList graph){
 //line 28
List<Node> nodeList = new ArrayList<Node>(graph.getSourceNodeSet());
//line 14
private ArrayList<ArrayList<Node>> tarjan(Node v, AdjacencyList list){

Additional explanation I did not put as title the kind of error I get because I don't know if this is an actual error or something else I am doing wrong, maybe I have to include the files (like in php..don't know). I am posting this in the hope that making it run is something simple since the code is there already.

Thank you all in advance!

1

There are 1 answers

1
Peter Svensson On BEST ANSWER

Most likely your missing some imports:

import java.util.List;

Also, you need to obtain the sourcecode for AdjacencyList from here That should fix your problems with compilation, might run into others later on :)