Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / (Graphs — graph functions) At the end of this document, you are given the basic code tin we implemented in the slides to create/read/print graphs

(Graphs — graph functions) At the end of this document, you are given the basic code tin we implemented in the slides to create/read/print graphs

Computer Science

(Graphs — graph functions) At the end of this document, you are given the basic code tin we implemented in the slides to create/read/print graphs. First copy/paste it into a file say graph . c and compile/run it. 3;°' gcc graph.c -o graph 3;• . /graph graph filename For sample graphs, again copy/paste the below graph data into a file undirectedgraphl . txt and directedgraphl . txt then run your program as ./graph undirectedgraphl.txt ./graph directedgraphl.txt 
. 0 •0 0  2 0 undirectedgraphl.txt directedgraphl.txt 6 8 0 6 8 1 1 2 3 1 2 3 1 3 6 2 3 1 2 3 1 3 1 6 2 9 5 3 5 2 3 5 2 4 2 5 4 5 3 4 5 3 4 6 6 4 6 6 5 6 1 5 6 1 
After studying and understanding the given code, first modify insert_edge ( ) function so that it can keep the link list sorted with respect to (w.r.t.) neighbor IDs. Second implement graph_copy ( ) to create a copy of the given graph. User will call the original graph as mygl and the copy as myg2 , for which we use the same pointer names in the program. Now extend the main function so that it can asks user to enter various commands in a loop and performs these commands on the related graphs. Accordingly, you also need to implement those functions and call them. Finally, when ending the main function, make sure you free the graphs.

Specifically, your program will ask user to enter a command and related parameters (if any) in a loop, and then perform the given commands. Here is the list of commands that your program must implement: [Your command names should be the same as written below so the TA can copy paste his/her test cases... for your own testing you can use initials etc, but your code should be able to handle the full command names below] 
* insert [mygi I myg2 ] x y w * delete [mygi I myg2 ] x y * printgraph [mygi I myg2 ] * printdegree [mygi I myg2 ] // if directed, print both in- and out-degree * printcomplement [mygi I myg2 ] * eliminatelinks [mygi I myg2] minW maxW * differentlinks [mygi I myg2] [mygi I myg2] * commonlinks [mygi I myg2] [mygi I myg2] * dfs [mygi I myg2 ] x * bfs [mygi I myg2 ] x * isconnected [mygi I myg2 ] * * numofconncomp quit [mygi I myg2 ] 
see more explanations that are at the end of this handout 
Please make sure your program processes the above comments as is so that TA can copy/paste his test cases. 
As always, make sure you release (free) the dynamically allocated memories if you allocate any memory in your programs. So, before submitting your program, run it with valgr ind to see if there is any memory leakage... 
Also if you need to debug your program, compile your programs with —g option and then run it with gdb and/or ddd. 
 

Option 1

Low Cost Option
Download this past answer in few clicks

19.99 USD

PURCHASE SOLUTION

Already member?


Option 2

Custom new solution created by our subject matter experts

GET A QUOTE