9 Topics

Member Avatar for
Member Avatar for brandon66

#include <iostream> #include <iomanip> #include <stack> #include <queue> #include <vector> #include <fstream> using namespace std; class graph { public: graph(); graph(int); //graph(int, int); void setEdge(int src, int dst); void printGraph();//print graph void bfs(int);//Breadth First Search void dfs(int);//Depth First Search void bfsSpan(int);//Breadth First Search Spanning Tree void dfsSpan(int);//DepthFirt Search Spanning Tree …

Member Avatar for brandon66
0
516
Member Avatar for skyyadav

I have written this code to find the cycle in graph public boolean hasCycle(int i, int[][] mat) { visited[i] = 1; // for( int i = 0; i < numNodes; i++ ) for (int j = 1; j < mat.length; j++) { if (mat[i][j] == 1 && i != j) …

Member Avatar for noorullah06
0
213
Member Avatar for SeanBlack0000

I am trying to create a graph from a 2d matrix of booleans. When the index [i][j] == 1, I need to create a link or edge from node[i] to node[j]. I am doing some thing wrong. I have created a class file with a struct node and some basic …

0
203
Member Avatar for IcyFire

I have to write a program that does BFS traversal. My code is mostly correct but i have an error somewhere. it prints repeated numbers in some cases and it's not supposed to. i'm not sure exactly what the problem is. I really hope someone will be able to help …

0
132
Member Avatar for minghags

Hello! I just want to ask you guys if anyone can help me reedit my program from BFS to DFS. I know how BFS works but i can't figure it out how to write the sintax. So i would please ask you guys if you could help me out. Heres …

Member Avatar for Labdabeta
0
420
Member Avatar for v3ga

I am doing a program to do dfs traversal given the adjacency matrix. My code follows: [CODE] #include <iostream> #define SIZE 10 using namespace std; bool M[SIZE][SIZE]; int flag[SIZE]; int dfsNum[SIZE], num; int n; void dfs( int u, int p ) { flag[u] = 1; dfsNum[u] = num++; for( int …

Member Avatar for v3ga
0
2K
Member Avatar for ana_1234

Hello, I am working on an assignment and I am so stuck and I have no clue how to get out. We are giving a maze and we are to find start and finish of the maze. The code is interpreted as giving the "walls" of the cell by looking …

Member Avatar for ana_1234
0
567
Member Avatar for XTRobot

Hello guys, can somebody give me example of some simple DFS problem and solution (Source code). I just need to understand DFS algorithm. Thanks XTRobot

Member Avatar for WaltP
0
107
Member Avatar for Slammer

Hi there. I need to write a recursive DFS function for graph which is implemented as follows: [CODE=c] struct nodes_arr { unsigned int position[50000]; unsigned int amount[50000]; node *next[50000]; } nodes_table[] = {0};[/CODE] [CODE=c]struct node { unsigned int position; unsigned int amount; node *next; };[/CODE] as a result i have …

1
109

The End.