import org.graffiti.graph.*;
import org.graffiti.plugin.io.*;
import org.graffiti.plugins.ios.importers.graphml.*;
import java.io.*;
import java.util.*;


public class TreeMapTemplate {

    public static void main(String[] args) {
    
        if (args.length < 1) {
            System.err.println("Please specify the file name of the graph "
                               + "to load!\n");
            System.exit(1);
        }

        Graph graph = new OptAdjListGraph();
        InputSerializer reader = new GraphMLReader();
        InputStream inputStream = null;
        try {
            inputStream = new FileInputStream(args[0]);
        } catch (FileNotFoundException fnfe) {
            System.err.println("file not found: " + fnfe + "\n");
        }
        try {
            reader.read(inputStream, graph);
        } catch (IOException ioe) {
            System.err.println("error reading file: " + ioe + "\n");
        }
        
        System.out.println("Successfully read graph from file "
                           + args[0] + "\n");

        Iterator it = graph.getNodesIterator();
        while (it.hasNext()) {
            Node node = (Node)it.next();
            System.out.println(node.toString() + "\n");
            // ... do sth with the node
        }
    
    }

}
