package javaapplication1;
class Vertex{
Vertex next;
char name;
Vertex(char chr){
name= chr;
next=NULL;
}
}
class Graph{
int nVerts=0;
int MAX_VERTS = 20;
Vertex vertexList[];
Graph(){
vertexList = new Vertex[MAX_VERTS];
}
public void addVertex(char lab) // argument is label
{
vertexList[nVerts++] = new Vertex(lab);
}
public void addEdge(int startnode , int nextnode){
Vertex tmp = vertexList[startnode] ;
for( ; tmp.next != NULL; tmp=tmp.next); // finding the spot to place the new Vertex
// Line A
}
}
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Graph g1= new Graph();
g1.addVertex('A');
g1.addVertex('B');
g1.addVertex('C');
g1.addVertex('D');
}
}
At line A
What do i have to do
Create a new Vertex or attach an already created vertex?

New Topic/Question
Reply




MultiQuote








|