#How can I make string as edges in a graph in java using Array in Arraylist implementation. PLEASE

1 messages · Page 1 of 1 (latest)

worldly frost
#

So i am trying to have string as edges in a graph in java using Array in Array list implementation but I have no idea how to do it. i tried doing something in the code I don't know if its correct or not. and it is also giving me an error. If you know any better approach for it as I will be using Dijkstra algorithm on it. So, Please let me know
class inlist{
String source;
String destination;
int time;

    inlist(String s,String d,int t){
        this.source=s;
        this.destination=d;
        this.time=t;
    }
}

class creategraph{
    int n=75;
    ArrayList<inlist> [] graph = new ArrayList[n]; // ERROR HERE SAYING { WAS EXPECTED BEFORE ; 
    graph=new LinkedList<inlist>();
    graph["new"]= new ArrayList<inlist>();
}
radiant surgeBOT
#

<@&987246717831381062> please have a look, thanks.

radiant surgeBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

proper thistle
#

Your syntax is incorrect in the end

#

Also why do u use a 2d list?

idle epoch
#

Why you do a array of arraylist, just do 2d array or ArrayList<ArrayList<inList>>

ebon bane
worldly frost
#

Hey i tried using ARRAYLIST OF ARRAYLIST i am just having one confusion like what is like this Arraylist(cityname)-> pointing to (my inlist which will be an array list). I am able to change the inlist and set parameter but i want my main vertex that is my outher arraylist to store name. But how???