package fr.hugol;

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

import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        System.setProperty("org.graphstream.ui", "swing");
        var graph = create();

        graph.display(false);

    }

    public static Graph create() {
        var graph = new SingleGraph("TP2");

        try {
            graph.read("src/main/resources/data/tp2.dgs");
        } catch (IOException | GraphParseException e) {
            throw new RuntimeException(e);
        }

        graph.nodes().forEach(node -> {
            node.setAttribute("ui.label", node.getId());
        });

        return graph;
    }
}
