- >? [closed]

Since your graph is undirected, you probably want to indicate both that u is connected to v and that v is connected to u. graph[u].Add(v); graph[v].Add(u); Then you can see the nodes connected to u by iterating graph[u]....

c++,function,recursion,adjacency-matrix,undirected-graph

As Linxi's comment says, you are copying the seen vector on every invocation of your recursive function so that the value returned back to your main function has exactly one nonzero entry at index i. Pass a reference instead (I've also passed the matrix as reference to const to prevent...

scala,graph,directed-graph,undirected-graph

There is no real difference in the implementation of an Edge, in both cases just the two connected nodes need to be specified. The difference would pop-up when you wanted to implement something else where the meaning of an edge needs interpretation. For instance, if you had a method areConnected(a:...

c++,performance,graph,breadth-first-search,undirected-graph

An edge whose deletion disconnects two connected components is called a bridge and there are linear-time algorithms for finding all the bridges in a graph (usually based on depth-first search). The Wikipedia article lists one of them (due to Tarjan) as an example. This paper also gives a simple algorithm...

java,graph,set,undirected-graph

You don't say here how mGraph is populated. If any of the entries are unmodifiable sets--especially if those are views of some other data structures--then it could cause that error message. To the chagrin of a lot of developers, many operations on the Java collections classes are optional, and may...

algorithm,graph,undirected-graph

Tarjan's algorithm was the first bridge finding algorithm in an undirected graph that ran in linear time. However a simpler algorithm exists and you can have a look at its implementation here. private int bridges; // number of bridges private int cnt; // counter private int[] pre; // pre[v] =...

graph,cycle,breadth-first-search,bfs,undirected-graph

Here below you will find the code to traverse a graph using BFS and find its cycles. #include <stdio.h> #include <queue> using namespace std; int nodes, edges, src; int graph[100][100], color[100], prev[100]; const int WHITE = 0; const int GRAY = 1; const int BLACK = 2; void print(int); int...