Пример #1
0
		public async static Task LoadFile(Subject subject, StorageFile file, int vertexCount)
		{
			DateTime dtStart = DateTime.Now;

			var fileName = file.Name;
			var fileParts = fileName.Split(new char[] { '-' });

			var idents = fileParts[0].Split(new char[] { '_' });
			var eventId = idents[0];

			StringBuilder sbAdjType = new StringBuilder();
			for (int i = 1; i < idents.Length; i++)
			{
				if (i > 1)
					sbAdjType.Append("-");

				sbAdjType.Append(idents[i]);
			}

			var adjType = sbAdjType.ToString();
			//var desc = fileParts[2];

			SubjectGraph subjectGraph = new SubjectGraph(vertexCount);
			subjectGraph.DataType = adjType;

			// Read in all the lines
			var lines = await Windows.Storage.FileIO.ReadLinesAsync(file);

			//subjectGraph.AddGraphLines(lines);

			for (int lineIdx = 0; lineIdx < lines.Count; lineIdx++)
			{
				var line = lines[lineIdx];
				var columns = line.TrimEnd().Split('\t');

				for (int colIdx = 0; colIdx < columns.Length; colIdx++)
				{
					if (lineIdx < vertexCount && colIdx < vertexCount)
					{
						// Only load the upper triangle
						if (colIdx > lineIdx)
							subjectGraph.AddEdge(lineIdx, colIdx, Math.Abs(Double.Parse(columns[colIdx])));
					}
				}
			}

			subject.AddGraph(subjectGraph);

			DateTime dtFinish = DateTime.Now;
			TimeSpan tsDiff = dtFinish - dtStart;
			double count = tsDiff.TotalMilliseconds;
		}