#### Category : graph

I am trying to go through a txt file with facebook data from 2009 and represent people as vertices on a graph, and friendships as edges. The code to make the graph works perfectly. I used it to calculate the average number of friends that people in this data set had. But when trying to ..

Can somebody please help me in implementing DFS in an iterative fashion for graph traversal? I’m Getting segmentation fault. I suspect that error is in if statement where I have written check 4. I am not sure what happens when the adjacency list do not exist for that index. What condition should I write in ..

I am having problems while running my program. Basically, my program is about the directed and undirected graph. My classes are nodes, edges, graph (abstract), directed graph, undirected graph. I used an adjacency list to store my nodes: undirect graph class node class However, I am getting an uninitialized error when creating my objects: Also, ..

In a graph, a permutation of the vertices [v1, v2, …..vn] is called a lucky permutation if for every vertex vi (where 1 <= i <= N-1), there exists an edge between vi and vi+1. You are given a graph with N vertices and M bidirectional edges. Write a program to calculate the number of ..

I am currently doing a c++ coding course online and am stuck trying to figure out how to complete the question. I need to create a weighted undirected graph using nodes that have strings as references rather than int’s. I need to be able to find the amount of vertex’s, edges and be able to ..

Language: C++ IDE: Visual Studio 2019 I wrote a program that collects data on random graphs (different probabilities for edges) to prove a Erdős–Rényi model threshold. each graph has 1000 vertexes and i need to run 15,000 cases (5,000 of which are diameter – and that takes a while) so naturally i would want to ..

I trying to solve this problem : https://codeforces.com/contest/216/problem/B so I find I could use bipartite and coloring each node whether 0 or 1 and I implement this code #include <bits/stdc++.h> using namespace std; int n; int m; int cnt = 0; vector<int> graph[110]; bool visit[110]; bool cross[110]; bool color[110]; void dfs(int i, int c) { ..