I need a program which generates a graph based on information contained in .txt file. For example, if it is written **1,7** , **7,6** in file, program must construct a graph connecting 1st and 7th, and 7th and 6th nodes.
I think for the beginning I need to have 2 arrays/lists, say, **X** and **Y** containing the first and second values of pairs given in .txt file, respectively. I wrote a code for this but it gives different Exceptions which I cannot handle. Here it is:

```
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class ReaddFile {
public static void main(String[] args) throws IOException{
    BufferedReader br  = new BufferedReader((new FileReader("my/path/here")));
    String line="";

    List<Integer> list_x = new ArrayList<Integer>();
    List<Integer> list_y = new ArrayList<Integer>();

    while((line=br.readLine())!=null){
        String[] t = line.split(",");
        int x = Integer.parseInt(t[0]);
        int y = Integer.parseInt(t[1]);
        list_x.add(x);
        list_y.add(y);
    }
    br.close();  
}
}

```

If I am on a right way, please help me to fix the code above and give me advice about how to continue and how to convert into graph those lists. Thanks in advance!  

P.S. I wrote a code which generates a graph using JUNG api, but problem is that I am including all node and edge information in code, while I need it to read from a .txt file. Here is the code:

```
import edu.uci.ics.jung.algorithms.layout.*;  
import edu.uci.ics.jung.graph.Graph;   
import edu.uci.ics.jung.graph.SparseMultigraph;   
import edu.uci.ics.jung.visualization.VisualizationViewer;   
import java.awt.*;   
import javax.swing.JFrame;   
public class GraphVis {   
Graph<Integer, String> g;

public GraphVis() {

g = new SparseMultigraph<Integer, String>();

g.addVertex((Integer) 1);
g.addVertex((Integer) 2);
g.addVertex((Integer) 3);
g.addVertex((Integer) 4);
g.addVertex((Integer) 5);
g.addVertex((Integer) 6);
g.addVertex((Integer) 7);
g.addVertex((Integer) 8);
g.addVertex((Integer) 9);
g.addVertex((Integer) 10);
g.addVertex((Integer) 11);
g.addVertex((Integer) 12);
g.addVertex((Integer) 13);
g.addVertex((Integer) 14);

g.addEdge("1", 1,2);
g.addEdge("2", 2, 6);
g.addEdge("3", 2, 6);
g.addEdge("4", 2, 7);
g.addEdge("5", 2, 7);
g.addEdge("6", 2,12);
g.addEdge("7", 2,3);
g.addEdge("8", 2,3);
g.addEdge("9", 3,4);
g.addEdge("10", 3,4);
g.addEdge("11", 3,6);
g.addEdge("12", 3,6);
g.addEdge("13", 3,7);
g.addEdge("14", 3,7);
g.addEdge("15", 3,12);
g.addEdge("16", 4,5);
g.addEdge("17", 4,13);
g.addEdge("18", 4,13);
g.addEdge("19", 4,8);
g.addEdge("20", 4,12);
g.addEdge("21", 4,12);
g.addEdge("22", 4,7);
g.addEdge("23", 4,7);
g.addEdge("24", 4,6);
g.addEdge("25", 4,6);
g.addEdge("26", 5,12);
g.addEdge("27", 5,11);
g.addEdge("28", 5,11);
g.addEdge("29", 5,13);
g.addEdge("30", 5,8);
g.addEdge("31", 5,8);
g.addEdge("32", 5,9);
g.addEdge("33", 5,9);
g.addEdge("34", 5,9);
g.addEdge("35", 5,14);
g.addEdge("36", 5,14);
g.addEdge("37", 5,10);
g.addEdge("38", 5,10);
g.addEdge("39", 6,12);
g.addEdge("40", 6,12);
g.addEdge("41", 6,12);
g.addEdge("42", 6,7);
g.addEdge("43", 6,7);
}   

public static void main(String[] args) {    
GraphVis sgv = new GraphVis();   
Layout<Integer, String> layout = new CircleLayout(sgv.g);    
layout.setSize(new Dimension(600,600));   
VisualizationViewer<Integer,String> vv = new          
VisualizationViewer<Integer,String>(layout);     
vv.setPreferredSize(new Dimension(750,750));     
JFrame frame = new JFrame("Graph View ");     
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    
frame.getContentPane().add(vv);    
frame.pack();    
frame.setVisible(true);    
}

```