private static Graph readInputFile(final String filename) {

        Graph graph = null;
        try {
            graph = new Graph(getNumberOfVertices(filename));
            BufferedReader reader = new BufferedReader(new FileReader(filename));
            String line = null;
            while ((line = reader.readLine()) != null) {
                String[] nodeData = line.split(" ");

                if (nodeData.length == 3) {
                    int vertex1 = Integer.parseInt(nodeData[0]);
                    int vertex2 = Integer.parseInt(nodeData[1]);
                    int weight = Integer.parseInt(nodeData[2]);
                    if (!graph.vertexExist(vertex1)) {
                        graph.addVertex(vertex1);
                    }
                    if (!graph.vertexExist(vertex2)) {
                        graph.addVertex(vertex2);
                    }
                    graph.addEdge(vertex1, vertex2, weight);
                }
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return graph;
    }