How can I remove all cycles from a graph like this? All edge lengths are one, and all edges are either vertical or horizontal. The graph is connected.
I want to compute the smallest number of edges that have to be removed in order for the graph to contain no cycles.
It would be really helpful if you included sample code (preferably C++, C or Java).
UPDATE: Apparently I have to find the number of vertices and edges. The problem I have gives a set of instructions like (down, left, up, down, left, left, up, down). You start from (0, 0) in the coordinate plane and move one unit in the specified direction. This will create a graph. How would I get the number of vertices and edges from this set of instructions?