In[1]:= (*==============================*)
(*输入地址:实际使用时,从这里开始*)pathGraph6 = \
"C:\\Users\\Administrator\\Desktop\\GenerateGraph\\点数为6\\6_6.g6";\
(*你的Graph6文件路径*)pathSaveText = \
"C:\\Users\\Administrator\\Desktop\\/your-txt-file.txt";\
(*你要保存的Text文件路径*)(*显示进程*)
filePosition = 0;
fileSize = FileByteCount[pathGraph6];
Dynamic[Column[{Row[{filePosition, "/", fileSize}],
ProgressIndicator[filePosition, {0, fileSize}]}]]
(*以数据流方式读写文件*)
sr = OpenRead[pathGraph6];
sw = OpenWrite[pathSaveText];
(*特殊处理第1行数据*)
g6String = StringReplace[ReadLine[sr], ">>graph6<<" -> ""];
matrixString =
ExportString[
Normal[AdjacencyMatrix[ImportString[g6String, "Graph6"]]],
"Table"] <> "\n\n";
WriteString[sw, matrixString];
(*处理余下的数据*)
While[(g6String = ReadLine[sr]) =!= EndOfFile,
filePosition = StreamPosition[sr];
matrixString =
ExportString[
Normal[AdjacencyMatrix[ImportString[g6String, "Graph6"]]],
"Table"] <> "\n\n";
WriteString[sw, matrixString];]
filePosition = fileSize;
Close /@ {sr, sw};
Out[4]= \!\(
DynamicBox[ToBoxes[
Column[{
Row[{$CellContext`filePosition, "/", $CellContext`fileSize}],
ProgressIndicator[$CellContext`filePosition, {
0, $CellContext`fileSize}]}], StandardForm],
ImageSizeCache->{200., {13., 18.}}]\)
\:6B63\:5728\:8BA1\:7B97In[1]:= StringReplace::strse: StringReplace[ReadLine[InputStream[C:\Users\Administrator\Desktop\GenerateGraph\点数为6\6_6.g6,72]],>>graph6<<->] 的位置 1 处应该是字符串或者由字符串组成的列表. >>
\:6B63\:5728\:8BA1\:7B97In[1]:= ImportString::string: 第一个参数 StringReplace[ReadLine[InputStream[C:\Users\Administrator\Desktop\GenerateGraph\点数为6\6_6.g6,72]],>>graph6<<->] 不是一个字符串. >>
\:6B63\:5728\:8BA1\:7B97In[1]:= AdjacencyMatrix::graph: 在 AdjacencyMatrix[ImportString[StringReplace[ReadLine[InputStream[C:\Users\Administrator\Desktop\GenerateGraph\点数为6\6_6.g6,72]],>>graph6<<->],Graph6]] 中 中位置 1 处应该是一个图对象. >>
\:6B63\:5728\:8BA1\:7B97In[1]:= ImportString::string: 第一个参数 ReadLine[InputStream[C:\Users\Administrator\Desktop\GenerateGraph\点数为6\6_6.g6,72]] 不是一个字符串. >>
\:6B63\:5728\:8BA1\:7B97In[1]:= AdjacencyMatrix::graph: 在 AdjacencyMatrix[ImportString[ReadLine[InputStream[C:\Users\Administrator\Desktop\GenerateGraph\点数为6\6_6.g6,72]],Graph6]] 中 中位置 1 处应该是一个图对象. >>
\:6B63\:5728\:8BA1\:7B97In[1]:= ImportString::string: 第一个参数 ReadLine[InputStream[C:\Users\Administrator\Desktop\GenerateGraph\点数为6\6_6.g6,72]] 不是一个字符串. >>
\:6B63\:5728\:8BA1\:7B97In[1]:= AdjacencyMatrix::graph: 在 AdjacencyMatrix[ImportString[ReadLine[InputStream[C:\Users\Administrator\Desktop\GenerateGraph\点数为6\6_6.g6,72]],Graph6]] 中 中位置 1 处应该是一个图对象. >>
\:6B63\:5728\:8BA1\:7B97In[1]:= ImportString::string: 第一个参数 ReadLine[InputStream[C:\Users\Administrator\Desktop\GenerateGraph\点数为6\6_6.g6,72]] 不是一个字符串. >>
\:6B63\:5728\:8BA1\:7B97In[1]:= General::stop: 在本次计算中,ImportString::string 的进一步输出将被抑制. >>
\:6B63\:5728\:8BA1\:7B97In[1]:= AdjacencyMatrix::graph: 在 AdjacencyMatrix[ImportString[ReadLine[InputStream[C:\Users\Administrator\Desktop\GenerateGraph\点数为6\6_6.g6,72]],Graph6]] 中 中位置 1 处应该是一个图对象. >>
\:6B63\:5728\:8BA1\:7B97In[1]:= General::stop: 在本次计算中,AdjacencyMatrix::graph 的进一步输出将被抑制. >>