public void writeToAdjacencyList(ArrayList<Node> network, String file){
        try 
        {
            BufferedWriter out = new BufferedWriter(new FileWriter(file));
            out.write("#Number of nodes:\n" + network.size() + "\n");
            out.write("#Node degrees:\n");
            for(int i=0;i<network.size();i++)
            {
                out.write(i + " " + network.get(i).getDegree() + "\n");
            }
            out.write("#Links:\n");
            Set<String> links = new HashSet<String>();
            for(Node N : network)
            {
                for(int i=0;i<N.getDegree();i++)
                {
                    if(!links.contains((N.getNeighbour(i).id + " " + N.id)))
                    {
                        links.add((N.id + " " + N.getNeighbour(i).id));
                        out.write(N.id + " " + N.getNeighbour(i).id + "\n");
                    }
                }
            }
            out.flush();
            out.close();
        } 
        catch (Exception ex) 
        {
            Logger.getLogger(NetworkGenerator.class.getName()).log(Level.SEVERE, null, ex);
        }
    }