I am trying to find all simple paths in a large directed graph (542 vertex, density ~ 5%) between two nodes. For this purpose, I use the algorithm from this thread. Unfortunately, my computer is running out of memory during this operation. I was thinking it would help to write the paths found directly to a text file, but I don't know how to do it in this case. Maybe, you'll have other suggestions as well. Here's the file with the adjacency matrix.
SetDirectory["C:\\Users\\crazyfrog\\Documents\\ДИПЛОМ"];
findPaths[a_?MatrixQ, s_Integer, t_Integer] :=
Module[{child, find},
child[v_] := Flatten@Position[a[[v]], Except@0, 1, Heads -> False];
find[v_, list_] :=
Scan[If[# === t, Sow[Append[list, #]],
If[FreeQ[list, #], find[#, Append[list, #]]]] &, child@v];
If[# =!= {}, First@#, {}] &@Last@Reap@find[s, {s}]];
findPaths[g_Graph, s_, t_] :=
Module[{nodes = VertexList@g, convert},
convert = Thread[nodes -> Range@Length@nodes];
findPaths[Normal@AdjacencyMatrix@g, s /. convert, t /. convert] /.
Reverse /@ convert];
<< JLink`;
InstallJava[];
ReinstallJava[JVMArguments -> "-Xmx1024m"]; data =
Import["test.xlsx"][[1]]; data2 = Round[data];
g = AdjacencyGraph[data2];
$HistoryLength = 0; findPaths[g, 1, 542] >> "result.txt"
Import's failure to read even modestly large excel files is a well known bug. http://mathematica.stackexchange.com/questions/42081/import-large-excel-file Best bet save your data in some intermediate format such as csv. – george2079 Mar 01 '14 at 12:57res=findP...amdres>>fileand post the exact error message. – george2079 Mar 01 '14 at 15:43