Question

Remarks: All the graphs here are without self loops and parallel edges, and anti-parallel edges. When...

Remarks: All the graphs here are without self loops and parallel edges, and anti-parallel edges. When we speak of a flow network, we mean there are capacities c(e) ? 0 on the edges, the graph G is directed with a source s and a destination t. In all the algorithms, always explain their correctness and analyze their complexity. The complexity should be as small as possible. A correct algorithm with large complexity, may not get full credit.

• Question 3: Given an undirected graph, give an algorithm that for every v returns the number of connected componnents in G ? v.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
dfs(node u)
  for each node v connected to u :
    if v is not visited :
      visited[v] = true
      dfs(v)


for each node u:
  if u is not visited :
    visited[u] = true
    connected_component += 1
    dfs(u)
Add a comment
Know the answer?
Add Answer to:
Remarks: All the graphs here are without self loops and parallel edges, and anti-parallel edges. When...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT