La bibliotheque GraphStream

Bonjour,

J'ai bien utilisée la documentation de GraphStream et j'ai crée mon graphe.J'ai besoin de sauvegarde l’exécution de ce graphe sous forme d'un fichier.DGS , comment je peux faire ça svp!!

1 réponse

  1. Modérateur
    Bonjour,

    La manipulation des fichiers se fait via les classes org.graphstream.stream.file.*
    Dans ton cas avec FileSinkDGS.writeAll(Graph graph, String fileName)
    1. Ah d'accord Merci, tu peux me donne un exemple svp et aussi Est ce que j'ai besoin d'un logiciel pour lire cette fichier.DGS??
    2. Modérateur
      @DjahidaBenahmedUn exemple :
      import org.graphstream.graph.implementations.SingleGraph;
      import org.graphstream.stream.file.FileSinkDGS;
      
      public class TestDGS {
          public static void main(String[] args) throws Exception {
              SingleGraph graph = new SingleGraph("graph", false, true);
              graph.addEdge("x", "a", "b");
              new FileSinkDGS().writeAll(graph, "C:/graph.dgs");
          }
      }

      Le fichier C:/graph.dgs peut se lire avec un éditeur de texte, il contient :
      DGS004
      null 0 0
      an "a"
      an "b"
      ae "x" "a" "b"
    3. Merci énormément