Answered Essay: Modify the DFs algorithm to determine whether or not the input graph is a connected grap

Modify the DFs algorithm to determine whether or not the input graph is a connected graph DEPTH FIRST SEARCH A labelled graph G = (V , E) (not necessarily connected) were traversed (DFI). is traversed, until all vertices have be reached. Uses recursion Input Output A forest F (a set of edges) and the order in which the vertices Method: Label each vertex v with DFI(v), which is the order in which it 3. for all v eV do DFI (v) := 0 4. while for some u, DFI (u)- 0 do begiin 5.DFS(u) 6. en Procedure DFS(v) 1. DFI (v):-i 3. for all ve A(v) do begin 4.if DFI (V) -0 then begin DFS(v) 7. end 8. end

Modify the DFs algorithm to determine whether or not the input graph is a connected graph. DEPTH FIRST SEARCH Input: A labelled graph G = (V , E) (not necessarily connected) Output: A forest F (a set of edges) and the order in which the vertices were traversed (DFI). Method: Label each vertex v with DFI(v), which is the order in which it is traversed, until all vertices have be reached. Uses recursion. i: = 1 F: = for all v elementof V do DFI (v): = 0 while for some u, DFI (u) = 0 do begin DFS(u) end Procedure DFS(v) DFI (v): = i i: = i + 1 for all v’ elementof A(v) do begin if DFI (v’) = 0 then begin F: = F Union { (v, v’)} DFS(v’) end end

Expert Answer

 

In DFS we traverse all nodes ot graph. When we traverse we insert value in DFI array either this node is visited or not. After calling DFS we will check in DFI for all nodes if any of node is not visited then we return false and we can say graph is not connected.

1.i:=1

2.F:=0

3.for all v varepsilon V do DFI(v):=0

4.while for some u, DFI(u) = 0 do begin

5. DFS(u)

6.end

7.if connected()

8. print “connected”

9.else

10. print “not connected”

procedure connected()

1.for all nodes u:

2. if DFI is 0

3. return false

4.return true

procedure DFS(v)

1.DFI(v): = i

2.i:= i+1

3.for all v’ varepsilon A(v) do begin

4. if DFI(v’) = 0 then begin

5. F: = F bigcup {(v,v’)}

6. DFS(v’)

7. end

8.end

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.

× How can I help you?