Questions tagged [undirected-graph]

An undirected graph has edges which have no orientation. It is a mathematical concept.

Definition of an undirected graph.

219 questions
-1
votes
1 answer

Why my Dijkstra's algorithm implementation in Java for undirected graph doesn't work?

My implementation for directed graph works fine. It's a "lazy" version because it uses simple priority queues instead of indexed ones. I changed the code to get a solution for undirected graphs but it doesn't work. dijkstra(int s) is a method of a…
-1
votes
1 answer

ArrayIndexOutOfBoundsException on generating maze graph with depth first search

I created a program that solves a maze that reads a text file input. I managed to solve it using Depth-first Search and the result was fine on small mazes like this: 11 3 2 3 0 3 1 4 5 4 5 7 6 7 7 8 8 9 9 10 0 5 Everything was fine solving small…
-1
votes
1 answer

Which algorithm+representation should I use for finding minimum path distance in a huge sparse undirected graph?

I need to find the minimum distance between two nodes in a undirected graph, here are some details The graph is undirected and huge(no of nodes is in order of 100,000) The graph is sparse, no of edges is less than no of nodes I am not interested in…
-2
votes
1 answer

Error in detecting cycle in undirected graph code

#include using namespace std; bool iscycle(list *adj,bool *visited,int i,int parent){ visited[i] = true; for(auto j : adj[i]){ if(!visited[j]) if(iscycle(adj,visited,j,i)) return true; …
-2
votes
1 answer

Matrix formalism NxN adjacency matrix

Let A be the NxN adjacency matrix of an undirected unweighted network, without self-loops. Let 1 be a column vector of N elements, all equal to 1. In other words 1 = (1, 1, ..., 1)T , where the superscript T indicates the transpose operation. Use…
-2
votes
2 answers

Shortest path of undirected graph with an extra weight edge provided

We are provided with an undirected graph, source node, destination node and the weight of an extra edge which you can use to connect any two nodes which were not connected earlier. You have to find the minimum weight of the path possible between the…
-2
votes
1 answer

DFS on undirected graph

I have an exercise for university where I have to write a DFS algorithm to run on an undirected graph. I also have to make the program sum the values of all nodes show the order in which the nodes were visited. Here is the given structure: #include…
Bruncky
  • 77
  • 12
-3
votes
1 answer

String Searching Algorithm that uses a graph ? C++

Code Instructions Hey guys. Above is a coding project I have been assigned. Im reading the instructions and am completely lost because I've never learned how to code an undirected graph? Not sure how my professor expects us to do this but I was…
-4
votes
1 answer

Determine if there is a path between all vertex pairs on an directed graph

Question I have a question about this problem: Given an directed graph that contains N vertices and M edges, please determine that "there is a path from vertex i to vertex j for all 1 <= i, j <= N". I want to solve for N <= 500, M <= 250000. I…
square1001
  • 1,196
  • 7
  • 20
1 2 3
14
15