views:

89

answers:

3

I am given a network defined by nodes and links. I have to search all loops in the network. No coordinates will be given for the nodes.

Is there any existing algorithm or library that can do this. Or can you please give me some idea how I can approach this problem? I am programming in .NET.

I draw a diagram to illustrate what I need here

+1  A: 

Try Distance vector Routing.

This algorithm finds the shortest path to all other nodes in a network from a node.

Davie
A: 

On the assumption that your edges are not directed and that there is a maximum of one edge between nodes then a http://en.wikipedia.org/wiki/Spanning%5Ftree Depth-first spanning tree will cover all nodes and indicate where the cycles (which is what I think you mean by loops) will occur. We use this algorithm for finding "rings" in chemical structures. There are many implementations in many languages - here's a tutorial with an applet (http://oneweb.utc.edu/~Christopher-Mawata/petersen2/lesson20.htm)

peter.murray.rust
A: 

The loops are called cycles, and this answer has a lot of informations for you.

elhoim