tarjans algorithm - strongly connected component in C -
I'm working on the implementation of associated components firmly using algorithms menace. I am giving input as a linked list of nodes and edges. However, the GCC compiler makes the segmentation mistake in the recurring function every time (where I am checking the nodes near the top of a loop).
What is wrong with this code
zero strong connection (integer vertexa) {struct sc_node * Ver; Ver = search_node (verttex); Ver-> sc_index = ind; // Use the information of the node's index Ver-> Sc_lowlink = ind; // node // Ver-> Accessed = 1 link access to information; Ind ++; Int w; Push (vertex); struct sc_node * to_link, * to_link1; int to_lowlink, to_index; Int Flalic; Int Min; int from_index; Shore_twara = edge_head; While (along _trov! = Null) access // linked list of edges (if (banks _ Trov- & gt; Se_veteks == Vertex) {to_link = search_node (edge_trav- & gt; to_vertex); To_lowlink = to_link- & gt ; sc_lowlink; to_index = to_link- & gt; sc_index; to_link1 = search_node (Vertex); flowlink = to_link1- & gt; sc_lowlink; from_index = to_link1- & gt; sc_index; if (to_index == 0) {Vertex = to_link- & gt; sc_data; printf ( "inside leakage"); strongconnect (Vertex); // recursive loop min = min (Flolink, Tu_lolink); to_link1- & gt; sc_lowlink = min;} of {min = min (Flolink, Se_indeks) ; to_link1-> sc_lowlink = min;} } Kinare_tavar Kinare_tavi- => gt;} Ver = search_node (Vertex); if (Ver-> gtc- slllink == Ver-> SC_index) {do {w = pop ()); printf ("% d \ t", w); } While (w! = Vertex); }}
I would suggest that you GCC -s And then run your program with valgrind . This is a very useful memory leak checker, with it you can find out that you are the program to reach an illegal memory situation. As Dougart pointed out, it seems that you are defending a NULL indicator.
Comments
Post a Comment