Commit 128264a4 authored by trh010's avatar trh010

cleaned up code comments and untracked .classpath to remove unnecessary

build dependencies
parent 5db7ce2e
This diff is collapsed.
/**
* specifies what an edge is
*
......@@ -8,23 +6,23 @@
*/
public class Edge {
/* the index of the vertice in the adjacency list that the edge goes to */
public int toVertex;
/* the index of the vertice in the adjacency list that the edge goes to */
public int toVertex;
/* weight of the edge */
public int weight;
/* weight of the edge */
public int weight;
/**
* simple constructor
*
* @param toVertex
* - int - index of a vertex in adjacency list
* @param weight
* - int - the weight of the edge (1 or 5)
*/
public Edge( int toVertex, int weight ) {
this.toVertex = toVertex;
this.weight = weight;
}
/**
* simple constructor
*
* @param toVertex
* - int - index of a vertex in adjacency list
* @param weight
* - int - the weight of the edge (1 or 5)
*/
public Edge(int toVertex, int weight) {
this.toVertex = toVertex;
this.weight = weight;
}
}
\ No newline at end of file
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
......@@ -78,7 +76,7 @@ public class Main {
}
in.close();
}
/**
* Queries the user for a Word, then lists the word's neighbors. Continues
* this cycle if desired. Provides the functionality necessary for Part I of
......@@ -91,20 +89,20 @@ public class Main {
System.out.println("Please provide the first 5 letter word: ");
String s1 = in.next();
int s1Handle = adjList.findStringHandle(s1.toUpperCase());
if (s1Handle == -1){
System.out.println("Input string " + s1
if (s1Handle == -1) {
System.out.println("Input string " + s1
+ " is not in the dictionary");
continue;
}
continue;
}
System.out.println("Please provide the second 5 letter word: ");
String s2 = in.next();
int s2Handle = adjList.findStringHandle(s2.toUpperCase());
if (s2Handle == -1){
System.out.println("Input string " + s2
if (s2Handle == -1) {
System.out.println("Input string " + s2
+ " is not in the dictionary");
continue;
}
continue;
}
System.out.println(adjList.outputToString(s1Handle, s2Handle));
boolean validResponse = false;
......@@ -138,7 +136,7 @@ public class Main {
try {
Main main = new Main();
main.createGraph(args[0]);
//main.queryUserPart1();
// main.queryUserPart1();
main.queryUserPart2();
} catch (Exception e) {
System.err.println("Error! - ");
......
import heap.HeapElt;
import java.util.ArrayList;
public class Vertex extends HeapElt {
/* in our case, this is a 5 letter word */
private String key;
/* An ArrayList of edges to all of the neighbors of this vertex */
private ArrayList<Edge> edges;
/*
* predecessor field for use in the dijkstra's algorithm and finding the
* shortest path
*/
private int pred;
/* index in the adjacency list */
private int adjListIndex;
/**
* simple constructor that initializes members
*
* @param word
* @param index
* @param neighbors
*/
public Vertex( String word, int index, ArrayList<Edge> neighbors ) {
this.key = word;
this.adjListIndex = index;
this.edges = neighbors;
pred = -1;
record = -1;
}
/*
* getters, setters, and addEdge functions
*/
public String getKey() {
return key;
}
public int getPred() {
return pred;
}
public void setPred( int pred ) {
this.pred = pred;
}
public int getAdjListIndex() {
return adjListIndex;
}
public void setAdjListIndex( int index ) {
this.adjListIndex = index;
}
public void addEdge( int n, int weight ) {
edges.add( new Edge( n, weight ) );
}
public void addEdge( Edge e ) {
edges.add( e );
}
public ArrayList<Edge> getEdges() {
return edges;
}
/* in our case, this is a 5 letter word */
private String key;
/* An ArrayList of edges to all of the neighbors of this vertex */
private ArrayList<Edge> edges;
/*
* predecessor field for use in the dijkstra's algorithm and finding the
* shortest path
*/
private int pred;
/* index in the adjacency list */
private int adjListIndex;
/**
* simple constructor that initializes members
*
* @param word
* @param index
* @param neighbors
*/
public Vertex(String word, int index, ArrayList<Edge> neighbors) {
this.key = word;
this.adjListIndex = index;
this.edges = neighbors;
pred = -1;
record = -1;
}
/*
* getters, setters, and addEdge functions
*/
public String getKey() {
return key;
}
public int getPred() {
return pred;
}
public void setPred(int pred) {
this.pred = pred;
}
public int getAdjListIndex() {
return adjListIndex;
}
public void setAdjListIndex(int index) {
this.adjListIndex = index;
}
public void addEdge(int n, int weight) {
edges.add(new Edge(n, weight));
}
public void addEdge(Edge e) {
edges.add(e);
}
public ArrayList<Edge> getEdges() {
return edges;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment