import org.graphstream.graph.Graph;
import org.graphstream.graph.Edge;
import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.SingleGraph;
import org.graphstream.stream.GraphParseException;

import java.io.IOException;
import java.util.Iterator;

public class TP1 {
    public static void main(String[] args) {
        Graph graph = new SingleGraph("exemple");
        try {
            graph.read("data/exemple.dgs");
        } catch (IOException e) {
            e.printStackTrace();
        } catch (GraphParseException e) {
            e.printStackTrace();
        }
        graph.display(false);

        graph.addAttribute("ui.stylesheet", "url('file:style/ssc.css')");

        // Iterators
        /*for (Edge e : graph.getEachEdge()) {
            System.out.println(e.getNode0().getId()+ " - " +e.getNode1().getId());
        }

        Iterator<Node> it = graph.getNodeIterator();
        while (it.hasNext()) {
            Node v = it.next();
            System.out.println(v.getId());
        }

        for (int i = 0; i<graph.getNodeCount(); i++) {
            Node v = graph.getNode(i);
            System.out.println(v.getId());
        }

        v.addAttribute("ui.label", v.getId();

        */

        graph.getNode("b").addAttribute("ui.class", "important");
        graph.getNode("c").addAttribute("ui.style", "fill-color:blue; size:20px;");

        graph.setAttribute("");
        graph.setAttribute("");
    }
}