Search code examples
javagraphgraphstream

How to store Graph in a text file using Graphstream


I know how to handle graphs using matrices and linked list. I am new to Graphstream. I want to know is there any in-built function in Graphstream in java to store/Read Graph type graphs in text files and what is the format of storing such graphs in a file?


Solution

  • Reading files using FileSource lists the file formats supported by concrete implementations of FileSource. It outlines the use of readAll(), as well as reading event-by-event from certain formats.

    • DGS (GraphStream)
    • DOT (GraphViz)
    • GML
    • TLP (Tulip)
    • NET (Pajek)
    • GraphML
    • GEXF (Gephi)

    In particular, The DGS File Format Specification describes DGS, the default GraphStream text file format. In outline, a FileSource connects a file to a graph:

    Graph g = …;
    FileSource fs = …;
    fs.addSink(g);
    fs.readAll(…);
    

    Can I get some sample DGS file online storing big Graph?

    Some small examples are shown here; a large example of the road network of Le Havre, France is cited here.