How to check if a graph is not a tree?

How to check if a given is undirected graph

tree

or not? Is there any correlation between the two?

I thought to check if the graph is connected or not? But is that enough?

+3


source to share


1 answer


None for an undirected graph, which must be a tree u, must be checked for 2 conditions.

1) The graph must be connected.



2) There should be no cycle.

DFS / BFS can be used to test both cases.

+1


source







All Articles