src/VertexColoring.Graphs/TrivialGraphFormatExtensions.cs
/// <summary>
/// Reads a graph in TGF from <paramref name="reader"/>.
/// </summary>
/// <param name="reader">Reads TGF containing graph.</param>
/// <returns>Graph read.</returns>
Reads a graph in TGF from .
Reads a graph in TGF from .
public static Graph ReadTgfGraph(this TextReader reader)
        {
            var vertices = new List<Vertex>();
            long lineNumber = 0;
            string line;
            while ((line = reader.ReadLine()) != null && !line.StartsWith("#"))
            {
                lineNumber++;
                var vertex = ReadTgfVertex(line);
                if (vertex != null)
                {
                    vertices.Add(vertex);
                }
            }
            lineNumber++;
            var vertexDictionary = vertices.ToImmutableDictionary(v => v.Id);
            var edges = new List<Edge>();
            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;
                var edge = ReadTgfEdge(line, vertexDictionary);
                if (edge != null)
                {
                    edges.Add(edge);
                }
            }
            return new Graph(vertices.ToImmutableSortedSet(), edges.ToImmutableSortedSet());
        }
public static Graph ReadTgfGraph ( this TextReader reader ) { var vertices = new List < Vertex > ( ) ; long lineNumber = 0 ; string line ; while ( ( line = reader . ReadLine ( ) ) != null && ! line . StartsWith ( " " ) ) { lineNumber ++ ; var vertex = ReadTgfVertex ( line ) ; if ( vertex != null ) { vertices . Add ( vertex ) ; } } lineNumber ++ ; var vertexDictionary = vertices . ToImmutableDictionary ( v => v . Id ) ; var edges = new List < Edge > ( ) ; while ( ( line = reader . ReadLine ( ) ) != null ) { lineNumber ++ ; var edge = ReadTgfEdge ( line , vertexDictionary ) ; if ( edge != null ) { edges . Add ( edge ) ; } } return new Graph ( vertices . ToImmutableSortedSet ( ) , edges . ToImmutableSortedSet ( ) ) ; }
Reads a graph in TGF from .
Reads a graph in TGF from .
None
TextReader
this
reader
Reads TGF containing graph.
Reads TGF containing graph .