Algorithm - Searching all loops in a network topology - algorithm

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

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

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_tree 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)

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

Related

Quicker algorithm

I have undirected, unweighed graph. I have a file that contains list of pairs (connected nodes). Each node may have any number of neighbours. I have to find one or all possible ways to traverse from a specified node to another.
I tried the depth first search - it works pretty well but my friends suggest that it may be pretty slowly. What other algorithms would you suggest? Could you please provide example pseudo code for them?

Finding nodes that partition a Graph

I have a non-directed graph that represents the connectivity between regions of a map. I'd like to identify groups of nodes (regions) that could be removed without creating graph partitions.
What I have tried:
Walking the tree (BFS, DFS...), storing the depths and selecting the nodes with the higher depth (O(n)). Once calculated, I can update the depths in O(~1) on each removal-addition by checking the depth of neighbour nodes (connectivity does not exceed a certain threshold)
Is there a cheaper way to do this? Also finding graph literature is also very hard if you don't know the academical term for the problem. My graphs are between 200 and 500 nodes.
The problem you are solving can be reduced to bridge finding problem in graph.
Algorithm :-
calculate all bridges in the graph using tarjan's method.
then remove a node which does not have bridge as a edge.
Then re-evaluate the bridges in subgraph of the removed node partitioned by bridges.
Continue doing 2 & 3 until there is no node to remove.
You want to find nodes which are not articulation points. Cf. this Wikipedia page for some algorithms allowing to solve the problem of detecting articulation points. See also this page. Finally, note some of these algorithms are already implemented in tools such as igraph.
PS: this is very similar to the problem identified by Vikram, but not exactly the same thing, since the focus is on nodes, and not links.

computing vertex connectivity of graph

Is there an algorithm that, when given a graph, computes the vertex connectivity of that graph (the minimum number of vertices to remove in order to separate the graph into two connected graphs). (Note that the graph may be already be disconnected). Thanks!
See:
Determining if a graph is K-vertex-connected
k-vertex connectivity of a graph
When you combine this with binary search you are done.
This book chapter should have everything you need to get started; it is basically a survey over algorithms to determine the edge connectivity and vertex connectivity of graphs, with pseudo code for the algorithms described in it. Page 12 has an overview over the available algorithms alongside complexity analyses and references. Most of the solutions for the general case are flow-based, with the exception of one randomized algorithm. The different general solutions optimize for different properties of the graph, so you can choose the most asymptotically efficient one beforehand. Also, for some classes of graphs, there exist specialized algorithms with better complexity than the general solutions provide.

What's the purpose of BFS and DFS?

I've learned how these algorithms work, but what are they used for?
Do we use them to:
find a certain node in a graph or
to find a shortest path or
to find a cycle in a graph
?
Both of them just visit all the nodes and mark them visited, and I don't see the point of doing that.
I am sort of lost here what I am learning.
BFS and DFS are graph search algorithms that can be used for a variety of different purposes.
One common application of the two search techniques is to identify all nodes that are reachable from a given starting node. For example, suppose that you have a collection of computers that each are networked to a handful of other computers. By running a BFS or DFS from a given node, you will discover all other computers in the network that the original computer is capable of directly or indirectly talking to. These are the computers that come back marked.
BFS specifically can be used to find the shortest path between two nodes in an unweighted graph. Suppose, for example, that you want to send a packet from one computer in a network to another, and that the computers aren't directly connected to one another. Along what route should you send the packet to get it to arrive at the destination as quickly as possible? If you run a BFS and at each iteration have each node store a pointer to its "parent" node, you will end up finding route from the start node to each other node in the graph that minimizes the number of links that have to be traversed to reach the destination computer.
DFS is often used as a subroutine in more complex algorithms. For example, Tarjan's algorithm for computing strongly-connected components is based on depth-first search. Many optimizing compiler techniques run a DFS over an appropriately-constructed graph in order to determine in which order to apply a specific series of operations. Depth-first search can also be used in maze generation: by taking a grid of nodes and linking each node to its neighbors, you can construct a graph representing a grid. Running a random depth-first search over this graph then produces a maze that has exactly one solution.
This is by no means an exhaustive list. These algorithms have all sorts of applications, and as you start to explore more advanced algorithms you will often find yourself relying on DFS and BFS as building blocks. It's similar to sorting - sorting by itself isn't all that interesting, but being able to sort a list of values is enormously useful as a subroutine in more complex algorithms.
Hope this helps!

What is a fast algorithm for finding critical nodes?

I'm looking for a quick method/algorithm for finding which nodes in a graph is critical.
For example, in this graph:
Node number 2 and 5 are critical.
My current method is to try removing one non-endpoint node from the graph at a time and then check if the entire network can be reached from all other nodes. This method is obvious not very efficient.
What are a better way?
See biconnected components. Calling them articulation points instead of critical nodes seems to yield better search results.
In any case, the algorithm consists of a simple depth first search where you maintain certain information for each node.
there are several better ways. research is always helpful
but since this is homework, the point of the exercise is likely to be to figure it out yourself
hint: how could you decorate the graph to tell you what nodes depend on what other nodes, and would this information perhaps be useful to spot the critical nodes?

Resources