Ejemplo n.º 1
0
        public static bool A_Check(StorageGraph graph)
        {
            if (ReferenceEquals(graph, DataSource.Error))
            {
                throw new Exception("input data not found");
            }

            //var componentsMax = graph.Nodes - (Math.Sqrt(8d * graph.Links + 1d) - 1d) * .5;
            var isGap = graph.IsGaps();

            //return componentsMax == 1d || !isGap;
            return(!isGap);
        }
Ejemplo n.º 2
0
        public static StorageGraph Build(StreamReader reader)
        {
            var result = new StorageGraph();

            while (!reader.EndOfStream)
            {
                var match = _match.Match(reader.ReadLine() ?? string.Empty);
                if (!match.Success)
                {
                    continue;
                }

                var left  = int.Parse(match.Groups["left"].Value);
                var right = int.Parse(match.Groups["right"].Value);
                result.Append(left);
                result.Append(right);
                result.Union(left, right);
            }

            return(result);
        }