c++ - Remove cycles from connected graph by finding vertices and edges -


enter image description here

how can remove cycles graph this? edge lengths one, , edges either vertical or horizontal. graph connected.

i want compute smallest number of edges have removed in order graph contain no cycles.

it helpful if included sample code (preferably c++, c or java).

update: apparently have find number of vertices , edges. problem have gives set of instructions (down, left, up, down, left, left, up, down). start (0, 0) in coordinate plane , move 1 unit in specified direction. create graph. how number of vertices , edges set of instructions?

since graph connected, if point is, write, to

compute smallest number of edges need removed in order graph contain no cycles

then don't need write algorithm. known result of removing cycles tree, , trees have same number of edges (the number of vertices minus one).


if point enumerate remaining edges (or removed edges), can use dfs (depth first search). specificially, in output of dfs, need retain marked there "tree edges".

while there c++ libraries dfs, might not enumerate edges way, , might easier code on own. can see, pseudocode quite simple.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -