Verifying information about the graph

66 views Asked by At

I'm having difficulty attempting to print the contents of my Graph using a toString method. Moreover, I do not receive an error when I add my Vertex to my Graph but I am unsure if I am properly adding my Vertexes. Thank you to anyone for any help!

Here's the App.

public class App 
{
public static void main(String[] args)
{
    File EdgeFile = new File("/User/src/main/java/edu.sdsu.cs/datastructures/threeVertexList.csv");
    File VertexFile = new File("User/src/main/java/edu.sdsu.cs/datastructures/threeEdgesList.csv");

    if (EdgeFile.exists() && EdgeFile.isFile() && VertexFile.exists() && VertexFile.isFile())   // Checks to see if Files are in existence
        {
            IGraph<String, Integer> Graph = new WDGraph<>();    // Instantiating the Graph
            BufferedReader in = null;

            try {
                in = new BufferedReader(new FileReader("cities.csv"));
                String read = null;

                while ((read = in.readLine()) != null) {
                    String[] split = read.split(",");

                    for (String part : split) {
                        Graph.addVertex(part);
                    }
                }
            } catch (IOException e) {
                    System.out.println("There was a problem: " + e);
                    e.printStackTrace();
                } finally {
                    try {
                        in.close();
                    } catch (Exception e) {
                    }
            }
        }

    else
        {
            System.out.println("Error: Incorrect number of input arguments (0 or 2 expected), X provided");
        }

        toString(); // method to overwrite to check contents of Vertices
  }
}

Here is my Graph.

class WDGraph<V,E> implements IGraph<V,E> {
private final List<IVertex> nodes;
private final List<IEdge> edges;

     WDGraph() {
        this.nodes = nodes;
        this.edges = edges;
    }

    private List<IVertex> getVertexes() {
        return nodes;
    }

    private List<IEdge> getEdges() {
        return edges;
    }
0

There are 0 answers