CoCalc Shared FilesQuestion Four Code.sagewsOpen in CoCalc with one click!
Authors: Patrick Coen, William A. Stein
Views : 17
# NAME: Patrick Coen # Description: Final Exam, SA405 # Outline: Code is not fully operational. In "Coen Function File," I have the following functions: # Depth First Search (With some modifications) # Depth First Search Visit # Random_Digraph: generates a random digraph # Reverse_Digraph: Reverses the direction of all edges on a digraph # Order_List: Orders the elements of a list # Reverse_List: Reverses a list load("Coen Function File.sage") #finish_times = [1, 40, 3, 100, 5] #length = len(finish_times) #ordered_finish_times = [0]*length #L = [i[0] for i in sorted(enumerate(finish_times), key=lambda x:x[1])] #L #for i in range(0,length): # j = L[i] # ordered_finish_times[i] = finish_times[j] #ordered_finish_times #List = [1,40,18,700,800] #output = Order_List(List) #output G = Random_Digraph(20,.1) for scc in G.strongly_connected_components_subgraphs(): scc.show()
Error in lines 1-1 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1013, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_salvus.py", line 3532, in load exec 'salvus.namespace["%s"] = sage.structure.sage_object.load(*__args, **__kwds)'%t in salvus.namespace, {'__args':other_args, '__kwds':kwds} File "<string>", line 1, in <module> File "sage/structure/sage_object.pyx", line 1075, in sage.structure.sage_object.load (/ext/sage/sage-8.0/src/build/cythonized/sage/structure/sage_object.c:12949) sage.repl.load.load(filename, globals()) File "/ext/sage/sage-8.0/local/lib/python2.7/site-packages/sage/repl/load.py", line 247, in load exec(preparse_file(open(fpath).read()) + "\n", globals) File "<string>", line 63 for i in range(_sage_const_0 ,length) ^ SyntaxError: invalid syntax